Flask-Mail SMTP服务器的配置 配置默认值说明MAIL-SERVERlocalhost电子邮件服务器的主机名或IP地址MAIL-PORT25电子邮件服务器的端口MAIL_USE_TLSFalse启用传输层安全(TLS,transport layer security) 协议MAIL_USE_SSLFalse启用安全套接层(SSL,secure sockets layer) 协议MAIL_USERNAMENone邮件账户的用户名MAIL_PASSWORDNone邮件账户的密码 在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) ...