Module Expr Str Import alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias alias Assign NameStore Call NameLoad NameLoad ClassDef bases AttributeLoad NameLoad attr body Expr Str ClassDef bases body Expr Str Assign NameStore Str Assign NameStore Dict Str Str Str Str Str Str Str Str Str Str Str Str Str Str ListLoad Str ListLoad ListLoad NameLoad NameLoad Str Str Num NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults kwarg body Assign NameStore Call NameLoad For NameStore ListLoad Str Str Str Str Str body Assign NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore ListLoad Str Str Str Str Str Str Str Str For NameStore NameLoad body Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign SubscriptStore NameLoad Index Str Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad AttributeLoad NameLoad attr attr Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults kwarg body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad If Call NameLoad SubscriptLoad NameLoad Index Str body Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Expr Call AttributeLoad NameLoad attr BinOpMod Str AttributeLoad AttributeLoad NameLoad attr attr If Call NameLoad SubscriptLoad NameLoad Index Str body Expr Call AttributeLoad NameLoad attr BinOpMod Str AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr orelse Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str If Call NameLoad SubscriptLoad NameLoad Index Str body Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str If CompareIs AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Expr Call AttributeLoad NameLoad attr Num If CompareGtE Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num Num body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults kwarg body Assign NameStore Call NameLoad Str Expr Call AttributeLoad NameLoad attr Str Assign SubscriptStore NameLoad Index Str SubscriptLoad NameLoad Index Str Assign SubscriptStore NameLoad Index Str Call AttributeLoad Str attr SubscriptLoad NameLoad Index Str Assign SubscriptStore NameLoad Index Str Call AttributeLoad Str attr SubscriptLoad NameLoad Index Str Assign SubscriptStore NameLoad Index Str Call AttributeLoad Str attr SubscriptLoad NameLoad Index Str If CompareNotIn SubscriptLoad NameLoad Index Str ListLoad NameLoad Str body Assign NameStore BinOpMod Str TupleLoad SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str orelse Assign NameStore SubscriptLoad NameLoad Index Str Assign SubscriptStore NameLoad Index Str Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults kwarg body Assign NameStore Str AugAssignAdd NameStore BinOpMod Str TupleLoad SubscriptLoad NameLoad Index Str Call AttributeLoad Str attr SubscriptLoad NameLoad Index Str AugAssignAdd NameStore BinOpMod Str Call AttributeLoad Str attr SubscriptLoad NameLoad Index Str AugAssignAdd NameStore BinOpMod Str Call AttributeLoad Str attr SubscriptLoad NameLoad Index Str If CompareNotIn SubscriptLoad NameLoad Index Str ListLoad NameLoad Str body AugAssignAdd NameStore BinOpMod Str TupleLoad SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str orelse AugAssignAdd NameStore BinOpMod Str SubscriptLoad NameLoad Index Str AugAssignAdd NameStore BinOpAdd NameLoad Str Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str BinOpAdd BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str NameLoad decorator_list decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list
N/A N/A 
The SMTP Extension provides the ability for applications to send email based
on the `smtplib <http://docs.python.org/dev/library/smtplib.html>`_ standard
library.

Requirements
------------

* No external depencies

Configuration
-------------

This extension honors the following configuration settings:

 * **to** - Default ``to`` addresses (list, or comma separated depending
   on the ConfigHandler in use)
 * **from_addr** - Default ``from_addr`` address
 * **cc** - 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``
 * **host** - The SMTP host server
 * **port** - The SMTP host server port
 * **timeout** - The timeout in seconds before terminating a connection
 * **ssl** - Whether to initiate SSL or not
 * **tls** - Whether to use TLS or not (requires SSL)
 * **auth** - Whether or not to initiate SMTP authentication
 * **username** - SMTP authentication username
 * **password** - SMTP authentication password

You can add these to any application configuration file under a
``[mail.smtp]`` section, for example:

**~/.myapp.conf**

.. code-block:: text

    [myapp]

    # set the mail handler to use
    mail_handler = smtp


    [mail.smtp]

    # default to addresses (comma separated list)
    to = me@example.com

    # default from address
    from = someone_else@example.com

    # default cc addresses (comma separated list)
    cc = jane@example.com, rita@example.com

    # default bcc addresses (comma separated list)
    bcc = blackhole@example.com, someone_else@example.com

    # default subject
    subject = This is The Default Subject

    # additional prefix to prepend to the subject
    subject_prefix = MY PREFIX >

    # smtp host server
    host = localhost

    # smtp host port
    port = 465

    # timeout in seconds
    timeout = 30

    # whether or not to establish an ssl connection
    ssl = 1

    # whether or not to use start tls
    tls = 1

    # whether or not to initiate smtp auth
    auth = 1

    # smtp auth username
    username = john.doe

    # smtp auth password
    password = oober_secure_password


Usage
-----

.. code-block:: python

    class MyApp(CementApp):
        class Meta:
            label = 'myapp'
            mail_handler = 'smtp'

    with MyApp() as app:
        app.mail.send('This is my fake message',
            subject='This is my subject',
            to=['john@example.com', 'rita@example.com'],
            from_addr='me@example.com',
            )
 N/A sys N/A smtplib email.header Header email.mime.multipart MIMEMultipart email.mime.text MIMEText core mail utils.misc minimal_logger is_true N/A LOG N/A minimal_logger __name__ SMTPMailHandler N/A N/A mail CementMailHandler N/A N/A 
    This class implements the :ref:`IMail <cement.core.mail>`
    interface, and is based on the `smtplib
    <http://docs.python.org/dev/library/smtplib.html>`_ standard library.

     Meta N/A N/A N/A Handler meta-data. N/A label smtp N/A config_defaults N/A to from_addr cc bcc subject subject_prefix host port timeout ssl tls auth username password N/A noreply@localhost N/A N/A None None localhost 25 30 False False False None None N/A _get_params N/A N/A self N/A kw N/A N/A params N/A dict N/A item N/A to from_addr cc bcc subject N/A N/A config_item N/A N/A N/A N/A self app config get N/A N/A self _meta config_section item N/A N/A params N/A item N/A N/A kw get item config_item N/A other_params N/A ssl tls host port auth username password timeout N/A item other_params N/A N/A N/A params N/A item N/A N/A N/A N/A self app config get N/A N/A self _meta config_section item N/A N/A params N/A subject_prefix N/A N/A N/A N/A self app config get N/A N/A self _meta config_section subject_prefix N/A params N/A send N/A N/A self body N/A kw N/A N/A 
        Send an email message via SMTP.  Keyword arguments override
        configuration defaults (cc, bcc, etc).

        :param body: The message body to send
        :type body: ``multiline string``
        :keyword to: List of recipients (generally email addresses)
        :type to: ``list``
        :keyword from_addr: Address (generally email) of the sender
        :type from_addr: ``str``
        :keyword cc: List of CC Recipients
        :type cc: ``list``
        :keyword bcc: List of BCC Recipients
        :type bcc: ``list``
        :keyword subject: Message subject line
        :type subject: ``str``
        :returns: Boolean (``True`` if message is sent successfully, ``False``
         otherwise)

        **Usage**

        .. code-block:: python

            # 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',
                )

         N/A params N/A N/A self _get_params kw N/A N/A is_true N/A params N/A ssl N/A N/A server N/A N/A smtplib SMTP_SSL N/A params N/A host N/A params N/A port N/A params N/A timeout N/A N/A N/A LOG debug N/A %s : initiating ssl N/A N/A self _meta label N/A N/A is_true N/A params N/A tls N/A N/A N/A N/A LOG debug N/A %s : initiating tls N/A N/A self _meta label N/A N/A N/A server starttls N/A N/A server N/A N/A smtplib SMTP N/A params N/A host N/A params N/A port N/A params N/A timeout N/A N/A is_true N/A params N/A auth N/A N/A N/A N/A server login N/A params N/A username N/A params N/A password N/A N/A N/A N/A self app debug True N/A N/A N/A N/A server set_debuglevel 9 N/A N/A N/A int N/A N/A sys version N/A 0 3 N/A N/A N/A N/A self _send_message server body params N/A N/A N/A N/A self _send_message_py2 server body params N/A N/A N/A server quit N/A _send_message N/A N/A self server body N/A params N/A N/A msg N/A MIMEMultipart alternative N/A N/A N/A msg set_charset utf-8 N/A N/A msg N/A From N/A params N/A from_addr N/A N/A msg N/A To N/A N/A ,  join N/A params N/A to N/A N/A msg N/A Cc N/A N/A ,  join N/A params N/A cc N/A N/A msg N/A Bcc N/A N/A ,  join N/A params N/A bcc N/A N/A N/A params N/A subject_prefix N/A None N/A N/A subject N/A %s %s N/A N/A params N/A subject_prefix N/A params N/A subject N/A N/A subject N/A params N/A subject N/A N/A msg N/A Subject N/A Header subject N/A part N/A MIMEText body N/A N/A N/A msg attach part N/A N/A N/A server send_message msg N/A _send_message_py2 N/A N/A self server body N/A params N/A N/A msg N/A msg N/A From: %s
To: %s
 N/A N/A params N/A from_addr N/A N/A ,  join N/A params N/A to N/A msg N/A Cc: %s
 N/A N/A ,  join N/A params N/A cc N/A msg N/A Bcc: %s
 N/A N/A ,  join N/A params N/A bcc N/A N/A N/A params N/A subject_prefix N/A None N/A N/A msg N/A Subject: %s %s

 N/A N/A params N/A subject_prefix N/A params N/A subject N/A N/A msg N/A Subject: %s

 N/A params N/A subject N/A msg N/A body N/A N/A N/A server sendmail N/A params N/A from_addr N/A N/A N/A params N/A to N/A params N/A cc N/A params N/A bcc msg N/A N/A load N/A N/A app N/A N/A N/A N/A N/A N/A app handler register SMTPMailHandler N/A