cement.core.mail
Cement core mail module.
- class cement.core.mail.MailHandler(**kw: Any)[source]
Bases:
MailInterface
,Handler
Mail handler implementation.
Configuration
This handler supports the following configuration settings:
to - Default
to
addresses (list, or comma separated depending on the ConfigHandler in use)from_addr - Default
from_addr
addresscc - Default
cc
addresses (list, or comma separated depending on the ConfigHandler in use)bcc - Default
bcc
addresses (list, or comma separated depending on the ConfigHandler in use)subject - Default
subject
subject_prefix - Additional string to prepend to the
subject
- class cement.core.mail.MailInterface(**kw: Any)[source]
Bases:
Interface
This class defines the Mail Interface. Handlers that implement this interface must provide the methods and attributes defined below. In general, most implementations should sub-class from the provided
MailHandler
base class as a starting point.- abstract send(body: str, **kwargs: Any) bool [source]
Send a mail message. Keyword arguments override configuration defaults (cc, bcc, etc).
- Parameters:
body (str) – The message body to send
- Keyword Arguments:
- Returns:
True
if message was sent successfully,False
otherwise- Return type:
Example
# Using all configuration defaults app.mail.send('This is my message body') # Overriding configuration defaults app.mail.send('My message body' to=['john@example.com'], from_addr='me@example.com', cc=['jane@example.com', 'rita@example.com'], subject='This is my subject', )