tea.msg Module

tea.msg.send_mail(subject, sender, to, message, html_message=None, cc=None, bcc=None, attachments=None, host=None, port=None, auth_user=None, auth_password=None, use_tls=False, fail_silently=False)

Easy wrapper for sending a single message to a recipient list. All members of the recipient list will see the other recipients in the ‘To’ field.

Note: The API for this method is frozen. New code wanting to extend the functionality should use the EmailMessage class directly.

tea.msg.send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password=None)

Given a datatuple of (subject, message, sender, recipient_list), sends each message to each recipient list. Returns the number of e-mails sent.

If auth_user and auth_password are set, they’re used to log in.

Note: The API for this method is frozen. New code wanting to extend the functionality should use the EmailMessage class directly.

Simple and complete library for sending emails

class tea.msg.mail.SMTPConnection(host=None, port=None, username=None, password=None, use_tls=None, fail_silently=False)

A wrapper that manages the SMTP network connection.

open()

Ensures we have a connection to the email server. Returns whether or not a new connection was required (True or False).

close()

Closes the connection to the email server.

send_messages(messages)

Sends one or more EmailMessage objects and returns the number of email messages sent.

class tea.msg.mail.EmailMessage(subject='', body='', sender=None, to=None, cc=None, bcc=None, attachments=None, headers=None, connection=None)

A container for email information.

Initialize a single email message (which can be sent to multiple recipients).

All strings used to create the message can be unicode strings (or UTF-8 bytestrings). The SafeMIMEText class will handle any necessary encoding conversions.

recipients()

Returns a list of all recipients of the email (includes direct addressees as well as Bcc entries).

send(fail_silently=False)

Sends the email message.

attach(filename=None, content=None, mimetype=None)

Attaches a file with the given filename and content. The filename can be omitted (useful for multipart/alternative messages) and the mimetype is guessed, if not provided.

If the first parameter is a MIMEBase subclass it is inserted directly into the resulting message attachments.

attach_file(path, mimetype=None)

Attaches a file from the filesystem.

class tea.msg.mail.EmailMultiAlternatives(subject='', body='', sender=None, to=None, cc=None, bcc=None, attachments=None, headers=None, connection=None)

A version of EmailMessage that makes it easy to send multipart/alternative messages. For example, including text and HTML versions of the text is made easier.

Initialize a single email message (which can be sent to multiple recipients).

All strings used to create the message can be unicode strings (or UTF-8 bytestrings). The SafeMIMEText class will handle any necessary encoding conversions.

attach_alternative(content, mimetype=None)

Attach an alternative content representation.

tea.msg.mail.send_mail(subject, sender, to, message, html_message=None, cc=None, bcc=None, attachments=None, host=None, port=None, auth_user=None, auth_password=None, use_tls=False, fail_silently=False)

Easy wrapper for sending a single message to a recipient list. All members of the recipient list will see the other recipients in the ‘To’ field.

Note: The API for this method is frozen. New code wanting to extend the functionality should use the EmailMessage class directly.

tea.msg.mail.send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password=None)

Given a datatuple of (subject, message, sender, recipient_list), sends each message to each recipient list. Returns the number of e-mails sent.

If auth_user and auth_password are set, they’re used to log in.

Note: The API for this method is frozen. New code wanting to extend the functionality should use the EmailMessage class directly.