rattail.mail

Email Framework

class rattail.mail.EmailHandler(config)[source]

Base class and default implementation for email handlers.

deliver_message(email, msg, recipients=<object object>)[source]

Deliver an email message using the given SMTP configuration.

email_is_available(email)[source]

Returns boolean indicating if the Email profile for the given key is “available” and should be exposed to users.

email_is_enabled(email)[source]

Returns boolean indicating if the given Email profile is “enabled” - that is, emails of its type should be sent as opposed to being suppressed.

Parameters:

email – An Email instance.

email_is_hidden(email)[source]

Returns boolean indicating if the given Email profile is “hidden” and should not be exposed to users.

Parameters:

email – Either an Email instance, or the key value for one.

get_all_emails(**kwargs)[source]

Retrieve the complete set of all Email profiles exposed by the app and installed packages.

get_available_emails(**kwargs)[source]

Retrieve the set of “available” Email profiles, i.e. those which should be exposed to the app users.

get_email(key, fallback_key=None, **kwargs)[source]

Return an email instance of the given type.

get_emails_from_module(module, **kwargs)[source]

Return all Email profiles from the given Python module.

iter_emails(warn=True)[source]

Iterate over all available email types.

should_record_attempts()[source]

Returns a boolean indicating if the app should make a record of all attempts to send email.

should_send_email_on_failure()[source]

Returns a boolean indicating if the app should send an email alert whenever sending of an email message fails.

use_entry_points()[source]

Returns a boolean indicating if the app should get its list of available emails from the setuptools entry points, instead of the (legacy) [rattail.mail] emails config setting.

rattail.mail.send_email(config, key, data={}, attachments=[], fallback_key=None, default_subject=None, enabled=<object object>, **kwargs)[source]

Send an email message of the given type, per config, with the given data and/or attachments.

class rattail.mail.Email[source]

Represents an email message, of a particular type. Various aspects of the message may be defined by a subclass and/or configuration.

Attribute key:

Unique key for a particular type of email. This is used to determine which template(s) will be used to generate the email body, as well as the email sender and recipients (via config/settings), etc.