美文网首页
使用Flask-Mail发送qq邮件

使用Flask-Mail发送qq邮件

作者: 默以太 | 来源:发表于2016-01-03 22:26 被阅读0次

    废话不多说,直接上代码:

    from flask import Flaskfrom

    flask_mail import Mail, Message

    app = Flask(__name__)

    app.config.update( 

          #EMAIL SETTINGS 

        MAIL_SERVER='smtp.qq.com', 

        MAIL_PORT=465, 

        MAIL_USE_SSL=True, 

        MAIL_USERNAME = 'qq号(如:123456)', 

        MAIL_PASSWORD = 'qq邮箱授权码'    )



    mail = Mail(app)

    @app.route("/")

    def index(): 

        msg = Message(subject="helloworld", sender='发送邮箱地址(如:123456@qq.com)', recipients=['接受邮箱地址(如:654321@qq.com)'])   

        msg.html = "testinghtml" 

        mail.send(msg) 

    if__name__ =='__main__':

        app.run(debug=True)

    相关文章

      网友评论

          本文标题:使用Flask-Mail发送qq邮件

          本文链接:https://www.haomeiwen.com/subject/rlushttx.html