Reputation: 37
i get the following error when trying a script thaat sends mail
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
Upvotes: 2
Views: 7616
Reputation: 63280
The getaddrinfo
function has this purpose:
The getaddrinfo function provides protocol-independent translation from an ANSI host name to an address.
If it fails it means that it cannot translate your given hostname to it's respective address. It's essentially doing a DNS query.
Your error number returned "11004" by getaddrinfo
has this message associated with it:
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.
It seems the name you're looking up has no correct data associated with it.
Are you sure your URL's are correct?
Links:
getaddrinfo
: http://msdn.microsoft.com/en-us/library/windows/desktop/ms738520(v=vs.85).aspx
WinSock Error Codes: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx
Upvotes: 5