cement.core.mail
Cement core mail module.
- class cement.core.mail.MailHandler(**kw: Any)[source]
Bases:
MailInterface,HandlerMail handler implementation.
Configuration
This handler supports the following configuration settings:
to - Default
toaddresses (list, or comma separated depending on the ConfigHandler in use)from_addr - Default
from_addraddresscc - Default
ccaddresses (list, or comma separated depending on the ConfigHandler in use)bcc - Default
bccaddresses (list, or comma separated depending on the ConfigHandler in use)subject - Default
subjectsubject_prefix - Additional string to prepend to the
subject
- class cement.core.mail.MailInterface(**kw: Any)[source]
Bases:
InterfaceThis 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
MailHandlerbase class as a starting point.- abstractmethod 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:
Trueif message was sent successfully,Falseotherwise- 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', )