email_handler.py

As simple an interface for email as seems viable.

>>> import email_handler
>>> bm = email_handler.BatchMailer('rgfowler@mdanderson.org', 'Package tester')
>>> response = bm.send_simple_mail('Batch mailer test', 'a better test')
>>> assert(const.EMPTY == response)
class email_handler.BatchMailer(alias=None, domain='mdanderson.org', sender=None, recipients=None, mailhost='mail.mdanderson.org')[source]

A very simple mailer that sets up a standard “mail chute” to drop simple messages in so that it can be referenced in arbitrary places in a package (specifically SyQADA) without having to track the sender or recipient list

sender the address from which the mail will come, or current user if not specified

alias the alias to be displayed for the sender if not None

recipients a list of recipient email addresses. If None, then the sender duplicate addresses will be purged.

address is used (common usage would be to notify the user of a process when it completes.

mailhost the SMTP host through which the mail will be routed.

send_simple_mail(subject, text)[source]

Send a pure-text message using the sender, recipients, and mailhost defined upon creation of the BatchMailer.

subject The message subject

text The message text

email_handler.DOMAIN = 'mdanderson.org'

The default domain attached to a bare unix userid

email_handler.MAILHOST = 'mail.mdanderson.org'