[英]gaierror socket.gaierror: [Errno 11001] getaddrinfo failed mail.send(msg)
I'm trying to send email with flask_email and I get this error: gaierror socket.gaierror: [Errno 11001] getaddrinfo failed mail.send(msg)`我正在尝试使用 flask_email 发送 email,但出现此错误:gaierror socket.gaierror: [Errno 11001] getaddrinfo failed mail.send(msg)`
from flask import Flask, render_template, request
from flask_mail import Mail, Message
app = Flask(__name__)
app.config['MAIL_SERVER']='smpt.gmail.com'
app.config['MAIL_PORT']=465
app.config['MAIL_USERNAME']= "micorreo@runchet.com"
app.config['MAIL_PASSWORD']= "miclave"
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
mail = Mail()
@app.route("/home", methods= ["POST", "GET"])
@app.route('/', methods= ["POST", "GET"])
def home():
if request.method == "POST":
msg = Message("hi!",
sender="micorreo@runchet.com",
recipients =['testEmail@gmail.com'])
msg.body = "testing"
mail.send(msg)
return "send email."
return render_template("index.html")
if __name__ == "__main__":
mail.init_app(app)
app.run(debug=True)
gaierror
means DNS resolution error, and in your case it probably means that the hostname does not exist. gaierror
表示 DNS 解析错误,在您的情况下,它可能意味着主机名不存在。 I'm not sure this is the problem, but my best guess is that this is due to a typo on line 6. You have:我不确定这是问题所在,但我最好的猜测是这是由于第 6 行的错字造成的。您有:
app.config['MAIL_SERVER']='smpt.gmail.com'
Notice that smpt
does not exist under the domain.请注意,域下不存在
smpt
。 Did you mean smtp.gmail.com
?您指的是
smtp.gmail.com
吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.