flask-mail发送邮件始终失败
Posted 露似真珠月似弓
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了flask-mail发送邮件始终失败相关的知识,希望对你有一定的参考价值。
1 from flask_mail import Mail,Message 2 from flask import Flask 3 import os 4 5 app=Flask(__name__) 6 app.config.update( 7 DEBUG = True, 8 MAIL_SERVER=\'smtp.qq.com\', 9 MAIL_PROT=25, 10 MAIL_USE_TLS = True, 11 MAIL_USE_SSL = False, 12 MAIL_USERNAME = \'4@qq.com\', 13 MAIL_PASSWORD = \'xxxxxxxx\', 14 #MAIL_PASSWORD = \'xxxxxxxx\', 15 MAIL_DEBUG = True 16 ) 17 mail=Mail(app) 18 19 20 @app.route(\'/\') 21 def index(): 22 # sender 发送方哈,recipients 邮件接收方列表 23 msg = Message("Hi!This is a test ",sender=\'4@qq.com\', recipients=[\'3@qq.com\']) 24 # msg.body 邮件正文 25 msg.body = "This is a first email" 26 # msg.attach 邮件附件添加 27 # msg.attach("文件名", "类型", 读取文件) 28 # with app.open_resource("F:\\2281393651481.jpg") as fp: 29 # msg.attach("image.jpg", "image/jpg", fp.read()) 30 31 mail.send(msg) 32 print ("OK") 33 return "Sent" 34 35 36 37 38 if __name__==\'__main__\': 39 app.run(debug=True)
发送一直失败,查网上比较靠谱的方法参考两篇文章
http://blog.csdn.net/huochen1994/article/details/51282093
http://tieba.baidu.com/p/3870714637 这个帖子的最后一答
以上是关于flask-mail发送邮件始终失败的主要内容,如果未能解决你的问题,请参考以下文章