Skip to main content

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

Release files for py-emails 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-emails 1.2.1
File Size Uploaded
py-emails-1.2.1.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-emails 1.2.1
File Interpreter ABI Platform
py_emails-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.7 kB

Release files / py-emails-1.2.1.tar.gz

Download URL py-emails-1.2.1.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
48670fcc8355ec54513bab0a516887c6ae18a1942bef5ae3879a02d0dc0f2b56
BLAKE2b-256 checksum
How to use checksums
58b17be6e1bd6763d8e60a9ebe98793e0f8459160180f234faa8897a6627d3cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.7

Release files / py_emails-1.2.1-py3-none-any.whl

Download URL py_emails-1.2.1-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77ac6f622c2c3d8139b97634fedefec7e23e9c0d2ca8b3e78a850f9a13cb2528
BLAKE2b-256 checksum
How to use checksums
747b9ec60b2ae47708912e38bba572b8b3f3b4d4313a0e1c91fe441f8527c8be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page