一切正常。我正在运行Ubuntu 16.04,已禁用防火墙,已激活Gmail上的“允许不安全的应用程序”设置,在配置后放置mail = Mail(app)
。
MAIL_SERVER= 'smtp.googlemail.com'
MAIL_PORT=587
MAIL_USE_TLS=1
MAIL_USERNAME='newlycreatedemail@gmail.com'
MAIL_PASSWORD='newlycreatedemailpawword'
ADMINS=['newlycreatedemail@gmail.com']
mail = Mail(app)
发送方功能:
@app.route('/confirmemail/',methods=['POST','GET'])
def confirmEmail():
user = User.query.filter_by(username = session['username']).first()
form = EmailForm()
if request.method == 'POST' and form.email.data == form.confirmEmail.data:
sendEmail('Confirm your email!',
sender=ADMINS[0],
recipients=form.email.data,
text_body="Merge!",
html_body="Merge html")
return render_template('emailconfirm.html',form=form)
else:
return render_template('sendconfirmationemail.html',form=form)