- Flask-Mail SMTP服务器的配置
配置 | 默认值 | 说明 |
---|
MAIL-SERVER | localhost | 电子邮件服务器的主机名或IP地址 | MAIL-PORT | 25 | 电子邮件服务器的端口 | MAIL_USE_TLS | False | 启用传输层安全(TLS,transport layer security) 协议 | MAIL_USE_SSL | False | 启用安全套接层(SSL,secure sockets layer) 协议 | MAIL_USERNAME | None | 邮件账户的用户名 | MAIL_PASSWORD | None | 邮件账户的密码 |
- 在python shell中发送电子邮件
>>> from hello import mail
>>> msg = Message('test email', sender='143XX@qq.com', recipients=['143XX@qq.com'])
>>> msg.body = 'This is the plain text body'
>>> msg.html = 'This is the <b>HTML</b>body'
>>> with app.app_context():
... mail.send(msg)
...
|