import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText fromaddr = "ssomeuserhere@gmail.com" toaddr = "someuser@gmail.com" msg = MIMEMultipart() msg['From'] = "someuser" msg['To'] = "someuser" msg['Subject'] = "SUBJECT OF THE MAIL" body = "YOUR MESSAGE HERE" msg.attach(MIMEText(body, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(fromaddr, "somepwd") text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit()
Standard input is empty
Standard output is empty
Traceback (most recent call last):
File "prog.py", line 12, in <module>
File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py", line 316, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.7/smtplib.py", line 291, in _get_socket
return socket.create_connection((host, port), timeout)
File "/usr/lib/python2.7/socket.py", line 557, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known