Skip to main content

Tools for constructing and sending emails

Project description

mailtools

Writing a web application? Want to send some emails from it? Mailtools can help!

  • Simple API for sending plain text messages, HTML and messages with attachments.

  • ThreadedMailer sends emails in the background and returns control to your application immediately, even when talking to slow remote servers.

  • Temporary sending failures are automatically retried.

  • Running your application in test mode? The RedirectMessages wrapper routes emails to a test address and not to live email addresses.

Usage

Creating a simple SMTP mailer:

from mailtools import SMTPMailer
mailer = SMTPMailer('127.0.0.1')

This mailer will block until messages are sent and won’t retry failures. Use ThreadedMailer to fix this:

mailer = ThreadedMailer(SMTPMailer('127.0.0.1'))

Sending a plain text message:

message = u'This is a plain text message'
mailer.send_plain(
        u'sender@example.com',
        [u'recipient@example.com'],
        u'hi',
        message
)

Sending an HTML message:

message = u'<html><body>Look! HTML!</body></html>'
mailer.send_html(
        u'sender@example.com',
        [u'recipient@example.com'],
        u'hi',
        message
)

Adding attachments:

message = u'index.rst is attached to this message'
mailer.send_plain(
        u'sender@example.com',
        [u'recipient@example.com'],
        u'hi',
        message,
        attachments=['index.rst']
)

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

mailtools-1.tar.gz (16.9 kB view details)

Uploaded Source

File details

Details for the file mailtools-1.tar.gz.

File metadata

  • Download URL: mailtools-1.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mailtools-1.tar.gz
Algorithm Hash digest
SHA256 cf77bbbdfb7be4411f5fbf9e6e8199cedf94e3f4438407fe9eda1bc31e142d2a
MD5 03042f9d61e043007f04f6829bd65a81
BLAKE2b-256 455b3d71702869921770ca2ff692905fde498eca5fee39d5bb7bae718f9e2fa3

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