Common interface for multiple e-mail methods
Project description
GitHub | PyPI | Documentation | Issues | Changelog
outgoing provides a common interface to multiple different e-mail sending methods (SMTP, sendmail, mbox, etc.). Just construct a sender from a configuration file or object, pass it an EmailMessage instance, and let the magical internet daemons take care of the rest.
outgoing itself provides support for only basic sending methods; additional methods are provided by extension packages.
See the documentation for more information.
Installation
outgoing requires Python 3.6 or higher. Just use pip for Python 3 (You have pip, right?) to install outgoing and its dependencies:
python3 -m pip install outgoing
Examples
A sample configuration file:
[outgoing]
method = "smtp"
host = "mx.example.com"
ssl = "starttls"
username = "myname"
password = { file = "~/secrets/smtp-password" }
Sending an e-mail based on a configuration file:
from email.message import EmailMessage
import outgoing
# Construct an EmailMessage object the standard Python way:
msg = EmailMessage()
msg["Subject"] = "Meet me"
msg["To"] = "my.beloved@love.love"
msg["From"] = "me@here.qq"
msg.set_content(
"Oh my beloved!\n"
"\n"
"Wilt thou dine with me on the morrow?\n"
"\n"
"We're having hot pockets.\n"
"\n"
"Love, Me\n"
)
# Construct a sender object based on the default config file (assuming it's
# populated)
with outgoing.from_config_file() as sender:
# Now send that letter!
sender.send(msg)
As an alternative to using a configuration file, you can specify an explicit configuration by passing the configuration structure to the outgoing.from_dict() method, like so:
from email.message import EmailMessage
import outgoing
# Construct an EmailMessage object using the eletter library
# <https://github.com/jwodder/eletter>:
from eletter import compose
msg1 = compose(
subject="No.",
to=["me@here.qq"],
from_="my.beloved@love.love",
text=(
"Hot pockets? Thou disgusteth me.\n"
"\n"
"Pineapple pizza or RIOT.\n"
),
)
msg2 = compose(
subject="I'd like to place an order.",
to=["pete@za.aa"],
from_="my.beloved@love.love",
text="I need the usual. Twelve Hawaiian Abominations to go, please.\n",
)
SENDING_CONFIG = {
"method": "smtp",
"host": "smtp.love.love",
"username": "my.beloved",
"password": {"env": "SMTP_PASSWORD"},
"ssl": "starttls",
}
with outgoing.from_dict(SENDING_CONFIG) as sender:
sender.send(msg1)
sender.send(msg2)
Project details
Release history Release notifications | RSS feed
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 outgoing-0.3.0.tar.gz
.
File metadata
- Download URL: outgoing-0.3.0.tar.gz
- Upload date:
- Size: 38.2 kB
- Tags: Source
- Uploaded using 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.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96a56c1205377a45ba47c8b7040de6f0af85ded29a4618c8291a45bdf5ec139d |
|
MD5 | eee3e4e6555979c4f242b46f4acb2bbb |
|
BLAKE2b-256 | a881f87af487103c8ce4fb8ba14b8a2a04883a0dd063d1f498de67741f7823f8 |
File details
Details for the file outgoing-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: outgoing-0.3.0-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using 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.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25aab99ef9b60de7a14cc10c6840432d37bd061ee8d43c4ab6bbc6414936cf9d |
|
MD5 | b8bdda6a6192ede6769492667e07a328 |
|
BLAKE2b-256 | b02091fbb5ba4537eab956826ce65e64a1fc258d8dfd30b31d0b42695684ca9d |