http://blog.csdn.net/stan_pcf/article/details/51098126
先进入邮箱设置 POP3/SMTP/IMAP
下面代码来自知乎
https://www.zhihu.com/question/50008398
from flask import Flask from flask_mail import Mail, Message app = Flask(__name__) MAIL_SERVER = 'smtp.163.com' MAIL_PORT = 465 MAIL_USE_TLS = False MAIL_USE_SSL = True MAIL_USERNAME = 'wewsa265@163.com' MAIL_PASSWORD = 'qweas123098' mail = Mail(app) app.route('/') def sendmail(): #Message(主题,发件人,收件人) msg = Message("Hello", sender="wewsa265@163.com", recipients=["1007720052@.qq.com"]) msg.body = "testing" msg.html = "<b>testing</b>" mail.send(msg) with app.app_context(): sendmail() return "发送成功" if __name__ == '__main__': app.run(debug=True)