运行脚本时出现此特定错误
超时错误:[WinError 10060]连接尝试失败,因为一段时间后连接方未正确响应,或者由于连接的主机未能响应而建立连接失败
代码:
from flask import Flask
from flask_mail import Mail, Message
app =Flask(__name__)
mail=Mail(app)
app.config['MAIL_SERVER']='smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = 'abc@gmail.com'
app.config['MAIL_PASSWORD'] = '********'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
mail = Mail(app)
@app.route("/", methods=['GET'])
def index():
msg = Message('Hello', sender = 'abc@gmail.com', recipients = ['xyz@gmail.com'])
msg.body = "Hello Flask message sent from Flask-Mail"
mail.send(msg)
return "Sent"
if __name__ == '__main__':
app.run(host = 'localhost', port = 8088, debug = True)
我尝试禁用代理。对我不起作用。还有其他解决方案吗?