http://blog.csdn.net/stan_pcf/article/details/51098126

先进入邮箱设置 POP3/SMTP/IMAP

flask 邮箱配置

下面代码来自知乎

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)

 

相关文章:

  • 2021-06-15
  • 2021-12-19
  • 2021-07-04
  • 2021-07-15
  • 2021-12-18
  • 2021-06-16
  • 2021-12-15
猜你喜欢
  • 2021-07-27
  • 2021-12-16
  • 2021-08-17
  • 2021-12-12
  • 2021-11-30
  • 2021-10-12
  • 2021-09-07
相关资源
相似解决方案