Skip to main content

Common interface for multiple e-mail methods

Project description

Project Status: Active — The project has reached a stable, usable state and is being actively developed. CI Status https://codecov.io/gh/jwodder/outgoing/branch/master/graph/badge.svg https://img.shields.io/pypi/pyversions/outgoing.svg MIT License

GitHub | PyPI | Documentation | Issues

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

msg1 = EmailMessage()
msg1["Subject"] = "No."
msg1["To"] = "me@here.qq"
msg1["From"] = "my.beloved@love.love"
msg1.set_content(
    "Hot pockets?  Thou disgusteth me.\n"
    "\n"
    "Pineapple pizza or RIOT.\n"
)

msg2 = EmailMessage()
msg2["Subject"] = "I'd like to place an order."
msg2["To"] = "pete@za.aa"
msg2["From"] = "my.beloved@love.love"
msg2.set_content(
    "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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

outgoing-0.1.0.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

outgoing-0.1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file outgoing-0.1.0.tar.gz.

File metadata

  • Download URL: outgoing-0.1.0.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for outgoing-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c1512a13bb4a5d6c0f4245d303c29f770fe326e81a134aa4f82076f240567d2
MD5 f0e79e7a70c619bbda306eae6407455a
BLAKE2b-256 d80b4f4b01d77ae19856df4e7a4fe7ee9abc30551bc9b690b9538c237f0816e9

See more details on using hashes here.

File details

Details for the file outgoing-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: outgoing-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for outgoing-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0032978eea33bfda8160cb7a20c78450461415d0efedb6b0b7b2ee10afc72938
MD5 d4621dde9a95efbdb98c2c667d6a461b
BLAKE2b-256 85fc3488428ad0204a33d76ad2ddff22adecf6d1dc97d98cac34237c69905e0c

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