-
Notifications
You must be signed in to change notification settings - Fork 0
Home
RectangleTangle edited this page Dec 17, 2012
·
13 revisions
This package provides a simple and straightforward way to programmatically send emails with Python. The main classes in this package are high-level abstractions of Python's smtplib and email libraries.
Features :
- A simple and intuitive way to send email messages
- Arbitrary files can easily be attached to messages
- Messages use proper MIME headers
- An easy to use (and automate) command-line interface
Demo :
# A simple demonstration of the library's core features.
# Fill in the strings with actual values.
import email_lib as el
att_0 = el.Attachment(path=r'attachment file name',
read_mode='plain or binary')
att_1 = el.Attachment(path=r'attachment file name',
read_mode='plain or binary')
msg = el.Message(from_='from address',
to=['to address 0', 'to address 1'],
subject='some subject',
body='body text of the message',
attachments=[att_0, att_1])
server = el.EmailServer(host='hostname', # smtp.gmail.com can be used for free
port='port number', # You could use port 587
username='username',
password=r'password')
server.send(msg) # This can also take a list of messages (for efficiency).
print 'sent'