uw.local.outgoing package

Submodules

uw.local.outgoing.cursor module

Cursor class for Outgoing mail sending.

Inherits from the usual cursor class with added methods for commonly-needed queries.

class uw.local.outgoing.cursor.Cursor(connection, cursor)[source]

Bases: uw.local.dbtools.Cursor

get_attachments(**parameters)
get_message(**parameters)
get_message_by_id(**parameters)
get_recipients(**parameters)
mark_message_sent(**parameters)

uw.local.outgoing.make_mail module

Outgoing mail handler API implementation.

This module provides Python routines for accessing the database functions that are responsible for creating the mail messages within the database.

class uw.local.outgoing.make_mail.mailout(cursor, sender, subject, content, content_html=None)[source]

Bases: object

An Outgoing mail message being created.

Parameters
  • cursor – DB connection cursor.

  • sender (uw.emailutils.emailaddr) – the sender of the email.

  • subject (str) – the subject of the email, or None.

  • content (str) – the contents of the email, or None.

Creating an instance of this class creates an email message in progress in the database.

add_attachment(content_maintype, content_subtype, content_charset, content, filename=None)[source]

Add an attachment.

The content_maintype and content_subtype together give the MIME type (e.g. “text/plain”). The content_charset is the charset for text content, or None. The content is the content as bytes or Unicode. If the content is supplied as Unicode, it will automatically be encoded in the specified content_charset or utf-8 if None is specified. The charset parameter will automatically be added to the MIME type.

add_recipient(type, recipient)[source]

Add a recipient.

Parameters
  • type (str) – the recipient type, one of “To”, “Cc”, “Bcc”.

  • recipient (uw.emailutils.emailaddr) – email recipient.

add_recipient_person(type, person_id)[source]

Add a recipient by their Person ID.

Parameters
  • type (str) – the recipient type, one of “To”, “Cc”, “Bcc”.

  • person_id (int) – the Person ID of the recipient.

property cursor

The DB connection cursor.

done()[source]

Finish the message and release it for sending.

property msg_id

The Message ID of the newly-created message.

This is initialized upon creation of the object.

static send(cursor, msg)[source]

Use Outgoing to send a message created using the Python email module.

Parameters
uw.local.outgoing.make_mail.main()[source]

Program entry point for sending a message assembled separately.

This is intended for testing and debugging. Take an email message on stdin and parse it into an email.message.Message object, then send it using a mailout object.

Module contents

Outgoing mail sending implementation.

This application allows for mail to be sent by recording in the database all the details of the mail to be sent. The information is committed along with the rest of the transaction, so that the mail is sent if and only if the rest of the transaction commits successfully.