Advertisement
Guest User

Untitled

a guest
Jun 17th, 2015
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1.  
  2. #import the email stuff we need
  3. import smtplib
  4. from email.mime.text import MIMEText
  5.  
  6. with open('emails.txt') as fp:
  7. # Create a text/plain message
  8. msg = MIMEText(fp.read())
  9.  
  10. msg['Subject'] = 'The contents of'
  11. msg['From'] = 'josharenson@gmail.com'
  12. msg['To'] = 'mcohen3@gmail.com'
  13.  
  14. # Send the message via our own SMTP server, but don't include the
  15. # envelope header.
  16. s = smtplib.SMTP('localhost')
  17. s.sendmail('mcohen3@gmail.com', 'mcohen3@gmail.com', msg.as_string())
  18. s.quit()
  19.  
  20.  
  21.  
  22. root@raspberrypi:/var/www/djotd/python# python page1.py
  23. Traceback (most recent call last):
  24. File "page1.py", line 15, in <module>
  25. s = smtplib.SMTP('localhost')
  26. File "/usr/lib/python2.7/smtplib.py", line 249, in __init__
  27. (code, msg) = self.connect(host, port)
  28. File "/usr/lib/python2.7/smtplib.py", line 309, in connect
  29. self.sock = self._get_socket(host, port, self.timeout)
  30. File "/usr/lib/python2.7/smtplib.py", line 284, in _get_socket
  31. return socket.create_connection((port, host), timeout)
  32. File "/usr/lib/python2.7/socket.py", line 571, in create_connection
  33. raise err
  34. socket.error: [Errno 97] Address family not supported by protocol
  35. root@raspberrypi:/var/www/djotd/python#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement