James Gardner: Home > Work > Code > Mail > 2.0.1 > API Documentation

Mail v2.0.1 documentation

API Documentation

Set of helpers to make sending email easier.

exception mail.MailError
Generic problem buidling a message or sending a mail
mail.multi(preamble=None, parts=[], **prepare_options)

Assemble a multi-part MIME message.

preamble
Text to display before the message parts which will be seen only by email clients which don’t support MIME.
parts
A list of the MIME parts to add to this message. You can use part() to create each part.
**prepare_options
Any extra keyword argument are sent to prepare() to add standard information to the message.
mail.part(data=None, filename=None, content_type=None, attach=True)

Create a MIME part to include in the message.

data
The data to include. If not specified the contents of the file specified by filename are used.
filename
The filename of the file to use for the data if data is not specified. If attach is True this filename is used as the filename of the attachment in the resulting email.
content_type
The content type of the part, for example "text/plain". If not specified the content type will be guessed from the filename.
attach
If True the part will be set up as an attachment. This is probably what you want for photos and the like but not what you want for plain text attachments which you want treated as the body of the email.
mail.plain(text, type='plain', charset=None, **prepare_options)
**prepare_options
Any extra keyword argument are sent to prepare() to add standard information to the message.
mail.prepare(message, from_name, from_email, to=[], cc=[], bcc=[], subject='(no subject)')
mail.send_sendmail(message, sendmail, verbose=False)

Send an email message Sendmail.

message
The prepared email message to send
sendmail
Path to the sendmail binary (or sendmail compatible binary) which is usually something like /usr/bin/sendmail or /usr/sbin/sendmail or /usr/local/bin/sendmail.
verbose
Set to True if you want all manner of information displayed spewed out for debugging.
mail.send_smtp(message, host, username=None, password=None, port=None, verbose=False)

Send an email message via SMTP.

message
The prepared email message to send
host
The SMTP server address you want to use to send the mail. You should not specify both sendmail and smtp.
username
The username for the SMTP server, if required.
password
The password for the SMTP server, if required.
port
The SMTP server’s port, if required.
verbose
Set to True if you want all manner of information displayed spewed out for debugging.
James Gardner: Home > Work > Code > Mail > 2.0.1 > API Documentation