从Flask-Mail发送邮件(SMTPSenderRefused 530) [英] Sending a mail from Flask-Mail (SMTPSenderRefused 530)

查看:124
本文介绍了从Flask-Mail发送邮件(SMTPSenderRefused 530)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Flask Mail应用程序中使用的应用程序配置(遵循Miguel Grinberg Flask开发手册):

The app configuration used in a Flask Mail application (following Miguel Grinberg Flask developlemt book) :

app.config['MAIL_SERVER'] = 'smtp.googlemail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = os.environ.get('MAIL_USERNAME')
app.config['MAIL_PASSWORD'] = os.environ.get('MAIL_PASSWORD')

邮件用户名和密码变量已正确设置并重新检查.尝试使用以下代码发送消息时,

The Mail Username and Password variables have been set correctly and rechecked. While trying to send a message using the following code,

from flask.ext.mail import Message
from hello import mail
msg = Message('test subject', sender='same as MAIL_USERNAME', recipients=['check@mail.com'])
msg.body = 'text body'
msg.html = '<b>HTML</b> body'
with app.app_context():
    mail.send(msg)

在发送时,应用程序一次又一次地导致以下错误:

While sending, the application is again and again resulting in the following error:

SMTPSenderRefused: (530, '5.5.1 Authentication Required. Learn more at\n5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 qb10sm6828974pbb.9 - gsmtp', u'configured MAIL_USERNAME')

是否有解决此错误的方法?

Any workaround for the error?

推荐答案

在深入研究所面临的问题时,我重新检查了Google的SMTP设置,

While digging into the issues faced, I rechecked the SMTP settings for Google,

更改

app.config['MAIL_SERVER'] = 'smtp.googlemail.com'

app.config['MAIL_SERVER'] = 'smtp.gmail.com'

成功了!

还要确保将完整用户名用作 Gmail SMTP用户名,即 example@gmail.com

Also make sure that the full username is used as Gmail SMTP username, i.e., example@gmail.com as shown in the image above.

希望这会有所帮助!

这篇关于从Flask-Mail发送邮件(SMTPSenderRefused 530)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆