Skip to main content

Simple wrapper around email and smtplib for composing and sending email messages in an intuitive, simple interface.

Project description

py-emails

Build Status Coverage Status

Simple wrapper around email and smtplib for composing and sending email messages in an intuitive, simple interface. Pure python, no dependencies outside of the standard library

Installation and use

Install with pip or your favorite package manager: pip install py-emails

Emails can be created declaratively:

from emails import Email

first_attachment = {
    'filename': 'example.png', 
    'content': open('example.png', 'rb').read()
}
other_attachment = {
    'filename': 'example.csv', 
    'content': open('example.csv', 'rb').read()
}
my_email = Email(
    sender='me@example.com', 
    subject='How are you?'
    body='Long time no see, we should get together!',
    attachments=[first_attachment, other_attachment]
)

Or using a template dictionary:

from emails import from_template

first_attachment = {
    'filename': 'example.png', 
    'content': open('example.png', 'rb').read()
}
other_attachment = {
    'filename': 'example.csv', 
    'content': open('example.csv', 'rb').read()
}
template = {
    'sender': 'me@example.com',
    'subject': 'How are you?',
    'body': 'Long time no see, we should get together!',
    'attachments': [first_attachment, other_attachment]
}
my_email = from_template(template)

Once you have the email object, sending it is as simple as specifying recipient(s) and an SMTP host:

recipients = ['person1@example.com', 'person2@example.com']
my_email.send(recipients, 'smtp.example.com')
my_email.send('person3@example.com', 'smtp.example.com')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for py-emails, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size py_emails-0.0.2-py3-none-any.whl (3.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size py-emails-0.0.2.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page