gpt4 book ai didi

python - 发送邮件错误python

转载 作者:太空宇宙 更新时间:2023-11-04 10:53:01 24 4
gpt4 key购买 nike

我在尝试发送邮件的脚本时收到以下错误

    import urllib.request
import re
import smtplib
from email.mime.text import MIMEText
from bs4 import BeautifulSoup
page=urllib.request.urlopen("http://www.crummy.com/")
soup=BeautifulSoup(page)
v=soup.findAll('a',href=re.compile('http://www.crummy.com/2012/07/24/0'))
for link in v:

w=link.get('href')


server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.starttls()
server.login( 'xxxxxxxxxxx', 'xxxxxxx' )
server.sendmail( 'xxxxxxxxx', 'xxxxxxxxx', "bonus question is up" )

Traceback (most recent call last): File "C:\Python32\bonus", line 14,
in server = smtplib.SMTP( "smtp.gmail.com", 587 ) File
"C:\Python32\lib\smtplib.py", line 259, in init File "C:\Python32\lib\smtplib.py", line 319, in connect self.sock = self._get_socket(host, port, self.timeout) File "C:\Python32 \lib\smtplib.py", line 294, in _get_socket return socket.create_connection((host, port), timeout) File "C:\Python32\lib\socket.py", line 386, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): socket.gaierror: [Errno 11004] getaddrinfo failed plse advice on the best way to go round it

最佳答案

getaddrinfo 函数有这个目的:

The getaddrinfo function provides protocol-independent translation from an ANSI host name to an address.

如果失败,则意味着它无法将您给定的主机名转换为相应的地址。它本质上是在进行 DNS 查询。

getaddrinfo 返回的错误号“11004”与此消息相关联:

Valid name, no data record of requested type. The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for. The usual example for this is a host name-to-address translation attempt (using gethostbyname or WSAAsyncGetHostByName) which uses the DNS (Domain Name Server). An MX record is returned but no A record—indicating the host itself exists, but is not directly reachable.

您正在查找的名称似乎没有与之关联的正确数据。

您确定您的网址正确吗?

链接:

获取地址信息:http://msdn.microsoft.com/en-us/library/windows/desktop/ms738520(v=vs.85).aspx

WinSock 错误代码:http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx

关于python - 发送邮件错误python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12494977/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com