Skip to content

Instantly share code, notes, and snippets.

@youqingkui
Forked from binderclip/flask-mail-qq.py
Created February 17, 2016 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youqingkui/d21023f3c8dc2fecc643 to your computer and use it in GitHub Desktop.
Save youqingkui/d21023f3c8dc2fecc643 to your computer and use it in GitHub Desktop.
用 Flask-Mail 通过 QQ 邮箱发送邮件
from flask import Flask
from 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 = 'QQIDHere',
MAIL_PASSWORD = 'QQPasswordHere'
)
mail = Mail(app)
@app.route("/")
def index():
msg = Message(subject="Hello",
sender='you@qq.com',
recipients=['recipient@recipient_domain.com'])
msg.html = "<b>testing</b> html"
mail.send(msg)
return '<h1>Sent</h1>'
if __name__ == '__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment