FlaskMail尝试连接Gmai时超时

2024-04-25 20:28:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个非常小的摇瓶应用程序,发送电子邮件使用摇瓶邮件,但当我运行它什么都没有发生,没有错误,没有例外什么!在

这是密码

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


Tags: namefromdebugimportcomtrueappflask