我有一个非常小的摇瓶应用程序,发送电子邮件使用摇瓶邮件,但当我运行它什么都没有发生,没有错误,没有例外什么!在
这是密码
from flask import Flask
from flask_mail import Mail, Message
app = Flask(__name__)
DEBUG = True
MAIL_SERVER = 'smtp.gmail.com'
MAIL_PORT = 465
MAIL_USE_TLS = False
MAIL_USE_SSL = True
MAIL_DEBUG = True
MAIL_USERNAME = "myemail@gmail.com"
MAIL_PASSWORD = "mypassword"
app.config.from_object(__name__)
mail = Mail(app)
@app.route("/")
def send_mail():
msg = Message("Hello",
sender="myemail@gmail.com",
recipients=["another_email@gmail.com"],
body="just testing",
)
mail.send(msg)
return "Message sent"
if __name__ == '__main__':
app.run()
更新
过了很长时间,我得到了这个错误
TimeoutError: [Errno 110] Connection timed out
看来我解决了我的问题 首先转到本页 解锁验证码
https://accounts.google.com/DisplayUnlockCaptcha
然后转到此页面以允许从不太安全的应用程序访问 https://www.google.com/settings/security/lesssecureapps
相关问题 更多 >
编程相关推荐