cement.ext.ext_smtp

Cement smtp extension module.

class cement.ext.ext_smtp.SMTPMailHandler(**kw)[source]

Bases: cement.core.mail.MailHandler

This class implements the IMail interface, and is based on the smtplib standard library.

class Meta[source]

Bases: object

Handler meta-data.

config_defaults = {'auth': False, 'bcc': [], 'cc': [], 'from_addr': 'noreply@localhost', 'host': 'localhost', 'password': None, 'port': '25', 'ssl': False, 'subject': None, 'subject_prefix': None, 'timeout': 30, 'tls': False, 'to': [], 'username': None}

Configuration default values

label = 'smtp'

Unique identifier for this handler

send(body, **kw)[source]

Send an email message via SMTP. Keyword arguments override configuration defaults (cc, bcc, etc).

Parameters:

body – The message body to send

Keyword Arguments:
 
  • to (list) – List of recipients (generally email addresses)
  • from_addr (str) – Address (generally email) of the sender
  • cc (list) – List of CC Recipients
  • bcc (list) – List of BCC Recipients
  • subject (str) – Message subject line
Returns:

True if message is sent successfully, False otherwise

Return type:

bool

Example

# Using all configuration defaults
app.mail.send('This is my message body')

# Overriding configuration defaults
app.mail.send('My message body'
    from_addr='me@example.com',
    to=['john@example.com'],
    cc=['jane@example.com', 'rita@example.com'],
    subject='This is my subject',
    )