简体   繁体   English

对于_socket.getaddrinfo(主机,端口,家庭,类型,原型,标志)中的资源:socket.gaierror:[Errno 11001] getaddrinfo失败

[英]for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 11001] getaddrinfo failed

I'm new to python.我是 python 的新手。 i'm trying to send email using python.我正在尝试使用 python 发送 email。 i have already enabled less secure app access and created app password but getting this error:我已经启用了不太安全的应用程序访问并创建了应用程序密码,但收到此错误:

Traceback (most recent call last):
  File "C:\My mask detection\xe1.py", line 11, in <module>
    with smtplib.SMTP('smtplib.gmail.com',587)as smtp:
  File "C:\Users\Adarsh C\AppData\Local\Programs\Thonny\lib\smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Users\Adarsh C\AppData\Local\Programs\Thonny\lib\smtplib.py", line 336, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "C:\Users\Adarsh C\AppData\Local\Programs\Thonny\lib\smtplib.py", line 307, in _get_socket
    self.source_address)
  File "C:\Users\Adarsh C\AppData\Local\Programs\Thonny\lib\socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "C:\Users\Adarsh C\AppData\Local\Programs\Thonny\lib\socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed 

I don't understand what this error is referring to.我不明白这个错误指的是什么。 i want to know where i have done wrong or do i want to do anything before i get in to code.我想知道我在哪里做错了,或者在我开始编写代码之前我想做些什么。

my code:我的代码:

import smtplib
import os

with smtplib.SMTP('smtplib.gmail.com',587)as smtp:
    smtp.ehlo()
    smtp.starttls()
    smtp.ehlo()

    smtp.login('helpdeskadhi@gmail.com','pnfnvboatmczopkn')
    subject = "hello"
    body = "Nice to meet you!"

    msg = f'Subject: {subject}\n\n{body}'

    smtp.sendmail('helpdeskadhi@gmail.com','helpdeskadhi@gmail.com',msg)
smtplib.SMTP('smtp.gmail.com',587)

声明:本站的技术帖子网页,遵循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导入错误&#39;socket.gaierror:[Errno 11001] getaddrinfo失败&#39; - 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 socket.gaierror:[Errno 11003] getaddrinfo失败 - socket.gaierror: [Errno 11003] getaddrinfo failed gaierror socket.gaierror: [Errno 11001] getaddrinfo 失败 mail.send(msg) - gaierror socket.gaierror: [Errno 11001] getaddrinfo failed mail.send(msg) 当我在 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