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

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.

Source Distribution

py-emails-0.0.1.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

py_emails-0.0.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file py-emails-0.0.1.tar.gz.

File metadata

  • Download URL: py-emails-0.0.1.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.7

File hashes

Hashes for py-emails-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d49c11a5946ad51d7667f902dea81590c61353d5ae847f61173293b78d8036fb
MD5 ff58fee3770ea16781405cc1a06c6a34
BLAKE2b-256 e15b905071e7344ab6b102fb0e6fbe331acb2a6ad5370d2b18169a90d6578087

See more details on using hashes here.

File details

Details for the file py_emails-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: py_emails-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.7

File hashes

Hashes for py_emails-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 662c8cdb61dc4cc8fe24febc65ae9f55239bdc0c1bad4d45fcf76148468b4892
MD5 b79e2b53cd6e0ab96dd86e84bf5bd992
BLAKE2b-256 e415d5363a6c9cfeab526fedd7a2bdd60a16f0f18e7704bfe45f650ffc697bd7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page