flask 版本和 flask-mail 版本都是最新的, 配置如下:
MAIL_SENDER = "[email protected]"
MAIL_SERVER = 'smtp.exmail.qq.com'
MAIL_USE_TLS = False
MAIL_USE_SSL = True
MAIL_PORT = 465
MAIL_USERNAME = os.environ.get('MAIL_USERNAME') or '[email protected]'
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
....
send_email("[email protected]", "test")
异常提示:
SMTPAuthenticationError: (521, 'Error: Invalid domain name, please use smtp.qq.com. More information at http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=371')
改成:smtp.qq.com后,也报错了:
SMTPSenderRefused: (501, 'mail from address must be same as authorization user')
如果不用 QQ 企业邮箱,改成自己的 QQ 邮箱则没有问题。
ps.已开启 POP/SMTP 服务、 MAP/SMTP 服务
求指教!