Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import the email stuff we need
- import smtplib
- from email.mime.text import MIMEText
- with open('emails.txt') as fp:
- # Create a text/plain message
- msg = MIMEText(fp.read())
- msg['Subject'] = 'The contents of'
- msg['From'] = 'josharenson@gmail.com'
- msg['To'] = 'mcohen3@gmail.com'
- # Send the message via our own SMTP server, but don't include the
- # envelope header.
- s = smtplib.SMTP('localhost')
- s.sendmail('mcohen3@gmail.com', 'mcohen3@gmail.com', msg.as_string())
- s.quit()
- root@raspberrypi:/var/www/djotd/python# python page1.py
- Traceback (most recent call last):
- File "page1.py", line 15, in <module>
- s = smtplib.SMTP('localhost')
- 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 571, in create_connection
- raise err
- socket.error: [Errno 97] Address family not supported by protocol
- root@raspberrypi:/var/www/djotd/python#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement