mailer
Module¶
agent | description |
---|---|
sendmail | (linux-only) uses either /usr/lib/sendmail or /usr/bin/mail |
SMTP | uses smtplib [1] |
[1] | smtplib: https://docs.python.org/2/library/smtplib.html |
TESTING THE CONFIGURATION¶
It is possible to test the email sending using the configuration file. (Alternatively, the GUI has a File menu item to send a test email.) First, the help message for the command:
[joeuser] $ pvMail_mail_test --help
usage: pvMail_mail_test [-h] recipient [recipient ...]
test the email sender from PvMail 3.1.0
positional arguments:
recipient email address(es), whitespace-separated if more than one
optional arguments:
-h, --help show this help message and exit
To test the email sending using the configuration file:
[joeuser] $ python ./mailer.py joeuser@example.com
An email message is sent from joeuser to joeuser@example.com:
1 2 3 4 5 6 7 | To: joeuser@example.com
Subject: PvMail mailer test message: sendmail
Date: Tue, 11 Nov 2014 13:17:31 -0600 (CST)
From: joeuser@example.com
This is a test of the PvMail mailer, v3.1.0
For more help, see: http://PvMail.readthedocs.org
|
Source Code Documentation¶
send a message by email to one or more recipients (by SMTP or sendmail)
Copyright (c) 2014-2017, UChicago Argonne, LLC. See LICENSE file.
-
PvMail.mailer.
sendMail_SMTP
(subject, message, recipients, smtp_cfg, sender=None, logger=None)[source]¶ send email message through SMTP server
Parameters: - subject (str) – short text for email subject
- message (str) – full text of email body
- recipients ([str]) – list of email addresses to receive the message
- smtp_cfg (dict) –
such as returned from
PvMail.ini_config.Config.get
server: required - (str) SMTP server user: required - (str) username to login to SMTP server port: optional - (str) SMTP port password: optional - (str) password for username connection_security: optional - (str) STARTTLS (the only choice, if specified) - sender (str) – “From” address, if None use smtp_cfg[‘user’] value
EXAMPLE:
>>> import PvMail.ini_config >>> smtp_cfg = PvMail.ini_config.Config().get() >>> recipients = ['joe@gmail.com', 'sally@example.org'] >>> subject = 'SMTP test message' >>> message = PvMail.ini_config.__doc__ >>> sendMail_SMTP(subject, message, recipients, smtp_cfg)
-
PvMail.mailer.
sendMail_sendmail
(subject, message, recipients, sendmail_cfg, sender=None, logger=None)[source]¶ send an email message using sendmail (linux only)
Parameters: - subject (str) – short text for email subject
- message (str) – full text of email body
- recipients ([str]) – list of email addresses to receive the message
- sendmail_cfg (dict) –
such as returned from
PvMail.ini_config.Config.get
user: required - (str) username to for sendmail (or similar) program - sender (str) – “From” address, if None use smtp_cfg[‘user’] value
- logger (obj) – optional message logging method
EXAMPLE:
>>> import PvMail.ini_config >>> sendmail_cfg = PvMail.ini_config.Config().get() >>> recipients = ['joe@gmail.com', 'sally@example.org'] >>> subject = 'sendmail test message' >>> message = PvMail.ini_config.__doc__ >>> sendMail_sendmail(subject, message, recipients, sendmail_cfg)
-
PvMail.mailer.
send_message
(subject, message, recipients, config)[source]¶ send an email message
Parameters: - subject (str) – short text for email subject
- message (str) – full text of email body
- recipients ([str]) – list of email addresses to receive the message
- config (dict) – such as returned from
PvMail.ini_config.Config