我無法發送電子郵件燒瓶郵件(http://pythonhosted.org/flask-mail/)發送郵件與瓶郵件
from flask.ext.sqlalchemy import SQLAlchemy
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
from flask.ext.mail import Mail, Message
import os
# configuration
DEBUG = True
SECRET_KEY = 'hidden'
USERNAME = 'secret'
PASSWORD = 'secret'
MAIL_SERVER='smtp.gmail.com'
MAIL_PORT=587
MAIL_USE_TLS = False
MAIL_USE_SSL= True
MAIL_USERNAME = '[email protected]'
MAIL_PASSWORD = 'password'
app = Flask(__name__)
mail = Mail(app)
@app.route('/minfo')
def send_mail():
msg = Message(
'Hello',
sender='[email protected]',
recipients=
['[email protected]'])
msg.body = "This is the email body"
mail.send(msg)
return "Sent"
當我去/明覆,我得到
12:25:57 web.1 | return socket.create_connection((port, host), timeout)
12:25:57 web.1 | File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 571, in create_connection
12:25:57 web.1 | raise err
12:25:57 web.1 | error: [Errno 61] Connection refused
我不知道是什麼正在打破或如何解決它,谷歌搜索了幾個小時。有人遇到過這個?
謝謝!我有app.config.from_object(__ name__)下面的郵件=郵件(應用程序),並像你顯示的移動。現在我得到了發送,但從未收到電子郵件:/ – ArniReynir
發現了,有一個錯字。所以問題解決使用你的解決方案謝謝! – ArniReynir