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

smtp_config = {
    'sender': 'you@example.com',
    'host': 'smtp.example.com'
}

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( 
    smtp_config, 
    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

smtp_config = {
    'sender': 'you@example.com',
    'host': 'smtp.example.com',
    'port': 587,
    'password': '<secret password>'
}
template = {
    'smtp_config': smtp_config,
    'subject': 'How are you?',
    'body': 'Long time no see, we should get together!'
}
my_email = from_template(template)

Once you have the email object, sending it is as simple as specifying one or more recipients:

import emails

smtp_config = {
    'sender': 'you@example.com',
    'host': 'smtp.example.com'
}
my_email = emails.Email(smtp_config)
my_email.send('person1@example.com')
my_email.send(['person2@example.com', 'person3@example.com'])

See examples.py for more in depth use cases

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-1.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

py_emails-1.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for py-emails-1.1.0.tar.gz
Algorithm Hash digest
SHA256 91192f81b8a9f786e6de35d5c4f89df6d153d5801b9dac1b0a9c7b13a550d412
MD5 84ea48e0ab565f86b8c8fc92fb3cc318
BLAKE2b-256 0522c0f639f088b4d5b7312d28301a08fce8b823c288f04dc4eacd72abb1adf4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_emails-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 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/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.7

File hashes

Hashes for py_emails-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8274fee21767cc0b46856e05d1c781d81d0628e030c0411cf748c31b73423fdd
MD5 32c1885c13bd6756104cf2ff85cebe76
BLAKE2b-256 4e224a0a38db15c60ca1483eb76b4a31df54a87e1df0ee39b3a2f47516a09de6

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