简体   繁体   English

gaierror socket.gaierror: [Errno 11001] getaddrinfo 失败 mail.send(msg)

[英]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.

相关问题 socket.gaierror:[Errno 11001] getaddrinfo 失败 - socket.gaierror: [Errno 11001] getaddrinfo failed (Python)socket.gaierror:[Errno 11001] getaddrinfo失败 - (Python) socket.gaierror: [Errno 11001] getaddrinfo failed Scapy导入错误'socket.gaierror:[Errno 11001] getaddrinfo失败' - Scapy import error 'socket.gaierror: [Errno 11001] getaddrinfo failed' 错误:- socket.gaierror:[Errno 11001] getaddrinfo 在获取请求中失败 - Error :- socket.gaierror: [Errno 11001] getaddrinfo failed in get request 如何解决:socket.gaierror: [Errno 11001] getaddrinfo failed - How to solve: socket.gaierror: [Errno 11001] getaddrinfo failed socket.gaierror: [Errno 11001] getaddrinfo 在 django 中失败 - socket.gaierror: [Errno 11001] getaddrinfo failed in django Flask-Mail 显示 socket.gaierror: [Errno 11001] getaddrinfo failed - Flask-Mail showing socket.gaierror: [Errno 11001] getaddrinfo failed socket.gaierror:[Errno 11003] getaddrinfo失败 - socket.gaierror: [Errno 11003] getaddrinfo failed 当我在 python 中使用套接字模块时,我收到此错误:'socket.gaierror: [Errno 11001] getaddrinfo failed' - I get this error:' socket.gaierror: [Errno 11001] getaddrinfo failed' when I use the socket module in python 服务器和客户端问题:socket.gaierror:[Erno 11001] getaddrinfo失败 - Server and client issue: socket.gaierror: [Erno 11001] getaddrinfo failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM