Sender provides a simple interface to set up SMTP and send email messages.

Install with the following command:

Sender is really easy to use. Emails are managed through a Mail instance:

Let’s construct one full message with all options:

The message could have a plain text body and(or) HTML:

# fromaddr will be "Name <name@example.com>"

It is possible to set fromaddr with a two-element tuple:

You can also set attribute individually:

To send one message, we need to create a Message instance:

To connect to the SMTP server and send messages, we need to create a Mail instance:

from sender import Mail mail = Mail ( "localhost" , port = 25 , username = "username" , password = "pass" , use_tls = False , use_ssl = False , debug_level = None )

You can set fromaddr to a mail instance, if the message sent by this mail instance does not set fromaddr , this global fromaddr will be used:

mail . fromaddr = ( "Name" , "name@example.com" )

Now let’s send our messages:

mail . send ( msg ) # or an iterable of messages mail . send ([ msg1 , msg2 , msg3 ])

There is one shortcut for sending one message quickly: