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
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
Built Distribution
File details
Details for the file py-emails-1.0.0.tar.gz
.
File metadata
- Download URL: py-emails-1.0.0.tar.gz
- Upload date:
- Size: 2.7 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dfe35906fd3cd6bc55eeb335452640564ac13e5ca6eb53d4da62bc3c7120c5c |
|
MD5 | 29c28af11f9272567ec9073397529fc3 |
|
BLAKE2b-256 | 51861870997b1fdb09f8bf5dedad4c6bcb20bea190512a10f4eb12dc79496c9f |
File details
Details for the file py_emails-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: py_emails-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.9 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 528741d85a1fcb73c80b7426fcb52f997b30242b2a369fad6cd5e08fe9926de1 |
|
MD5 | 25e201312dadd97f10c1ac9aa9700e54 |
|
BLAKE2b-256 | d35d58d5850fbe042f961aaa304a1636d2d75f76e5679ac6b24bdc23f2f74a28 |