使用Flask-Mail发送qq邮件

2016-01-03  本文已影响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)

上一篇 下一篇

猜你喜欢

热点阅读