Dramatically simplify sending emails from your python app.

jpsca jpsca Last update: Mar 27, 2021

Mailshake logo

Mailshake

Build Status

Although Python makes sending email relatively easy via the smtplibmodule, this library provides a couple of light wrappers over it.

These wrappers make sending email extra quick, easy to test emailsending during development, and provides support for platforms thatcan't use SMTP.

Mailers availiable:

  • SMTPMailer
  • AmazonSESMailer
  • ToConsoleMailer (prints the emails in the console)
  • ToFileMailer (save the emails in a file)
  • ToMemoryMailer (for testing)
  • DummyMailer (does nothing)

Usage:

from mailshake import SMTPMailermailer = SMTPMailer()mailer.send(    subject='Hi',    text_content='Hello world!',    from_email='[email protected]',    to=['[email protected]', '[email protected]'])

You can also compose several messages and send them at the same time:

from mailshake import SMTPMailer, EmailMessagemailer = SMTPMailer()messages = []email_msg = EmailMessage(    "Weekend getaway",    "Here's a photo of us from our trip.",    "[email protected]",    "[email protected]")email_msg.attach_file("picture.jpg")messages.append(email_msg)#…mailer.send_messages(*messages)

Install for development

First, create an activate a virtualenv. eg:

python -m virtualenv .venvsource .venv/bin/activate

Then run pip install -e .[dev] or make install. This will install the library in editable mode and all its dependencies.

Subscribe to our newsletter