I got this errors when try to send email using STMP :
1 2 3 4 5 6 7 8 9 10 | local_hostname=DNS_NAME.get_fqdn()) File "/usr/lib/python2.7/smtplib.py", line 249, in __init__ (code, msg) = self.connect(host, port) File "/usr/lib/python2.7/smtplib.py", line 309, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/lib/python2.7/smtplib.py", line 284, in _get_socket return socket.create_connection((port, host), timeout) File "/usr/lib/python2.7/socket.py", line 553, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): gaierror: [Errno -2] Name or service not known |
Apparently, this errors occurs because of this :
1 2 3 4 5 | EMAIL_USE_TLS = True EMAIL_HOST = ‘smtp.google.com’ EMAIL_PORT = 587 EMAIL_HOST_PASSWORD = ‘xxxxxxxxx’ EMAIL_HOST_USER = ‘xx@gmail.com’ |
Yes, this part the main cause:
1 | EMAIL_HOST = ‘smtp.google.com’ |
Which it should be :
1 | EMAIL_HOST = ‘smtp.gmail.com’ |
So, if you got this errors, please check your SMTP HOST address whether is correct or not.