Pyng: SMTP pager

Description

SMTP Pager is able to send email alerts and notifications using an external SMTP server.

SMTP Pager requires curl command to be present in $PATH.

Options

SMTP Pager supports following options, which may be used upon creation of a new pager object:

url
Target SMTP server URL (smtp://host:port or smtps://host:port) (required)
sender
Sender information to use directly in the message From header (required)
headers
Dictionary of message headers to use in the message
tls
Set to True to require TLS for the connection, only relevant for smtp:// URL
noverify
Set to True to skip TLS certificate verification
ipv
IP version to use when resolving addresses (IPv6 or IPv4)
auth
Username and password to use for LOGIN server authentication, may be provided as a tuple with two elements, or as a string with username and password separated with colon (":")

In addition, SMTP Pager supports following generic pager settings:

desc
Pager description
target
Default pager target, which is used as default recipient of pager messages in the pager's alert() and notify() methods

Example

pager = SMTPPager(
    url='smtps://smtp.domain.example:465',
    sender='pyng <pingmaster@domain.example>',
    target='user@domain.example',
    headers={
        'X-Pager': 'SMTP',
    },
    ipv=4,
    auth='user:sup3rs3cr3t',
)

# now you may use pager.alert() in the alert parameter in the checks,
# and pager.notify() in the notify paramter in the checks. alternatively,
# you may assign result of those methods to variables and use those in the
# checks

alerter = pager.alert()
notifier = pager.notify()

# alerter may be used in the alert parameter, and notifier in the notify parameter

# alert() and notify() methods will call send, with target
# given in alert() or notify(), or the default target given
# when creating the pager object

# calling send() may be used to test the pager
#pager.send('short summmary', 'longer message...')
    

Return to Pyng