.. _smtp-presentation:

********************
SMTP
********************

.. index:: presentations; SMTP

Overview
====================

This presentation is designed to monitor a specified channel and treat
it as a flag to indicate whether or not to trigger an email being sent
to an SMTP server.

Configuration
====================

A typical SMTP configuration block looks like this::

    - name: smtp0
      driver: presentations.smtp.smtp:SMTPHandler
      settings: 
          monitored_channel: <channel name>
          server_address: <SMTP server IP address>
          to_address: <destination email address>
          subject: "Limit exceeded"

Settings
--------------------

monitored_channel (required)
    Channel containing the condition (usually a channel generated with
    the Transforms device) to perform the e-mail call.

server_address (required)
    IP address of the SMTP server.

to_address (required)
    The email address to send the email to.

from_address (optional, default: digi_dia@digi.com)
    The "from" address of the email.

subject (optional, default: iDigi Dia Alert)
    Subject text of the email.

port (optional, default: 25)
    The port of the SMTP server.

Usage
====================
The monitored channel is defined by the configuration file setting 
'monitored_channel'. The channel is then subscribed to so when a new sample
is given, the value of the sample is evaluated in a boolean context, and if 
true, builds a message and queues it for sending.

The generic intention of the email presentation is to be used with the 
transform device. Use the transform device to perform a calculation or a group
of comparisons. For example::

    expr = '(condition1) and (condition2) and (condition3)'

If those three conditions are met, the transform device channel will be
evaluated as true and an email message will be queued, provided the SMTP
presentation was configured to monitor the transform device.


