From 8868f1e9d6af0250fe58dc230ab9480cda90c78b Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Fri, 10 Apr 2015 00:22:41 +0300 Subject: [PATCH] add a script to check smtp with starttls connectivity --- master/contrib/check_smtp.py | 35 ++++++++++++++++++++++++ master/docs/manual/cfg-statustargets.rst | 4 +++ 2 files changed, 39 insertions(+) create mode 100755 master/contrib/check_smtp.py diff --git a/master/contrib/check_smtp.py b/master/contrib/check_smtp.py new file mode 100755 index 00000000000..09c37d8195e --- /dev/null +++ b/master/contrib/check_smtp.py @@ -0,0 +1,35 @@ +#! /usr/bin/python -tt +""" +This script helps to check that the SMTP_HOST (see below) would accept STARTTLS +command, and if LOCAL_HOST is acceptable for it, would check the requested user +name and password would allow to send e-mail through it. +""" + +from smtplib import SMTP + +from getpass import getpass + +SMTP_HOST = 'the host you want to send e-mail through' +LOCAL_HOST = 'hostname that the SMTP_HOST would accept' + +def main(): + """ + entry point + """ + + server = SMTP(SMTP_HOST) + + server.starttls() + + print server.ehlo(LOCAL_HOST) + + user = raw_input('user: ') + password = getpass('password: ') + + print server.login(user, password) + server.close() + +if __name__ == '__main__': + main() + +# vim:ts=4:sw=4:et:tw=80 diff --git a/master/docs/manual/cfg-statustargets.rst b/master/docs/manual/cfg-statustargets.rst index 9dc51a5a4d7..76331d0daac 100644 --- a/master/docs/manual/cfg-statustargets.rst +++ b/master/docs/manual/cfg-statustargets.rst @@ -94,6 +94,10 @@ If your SMTP host requires authentication before it allows you to send emails, t smtpUser="myuser@example.com", smtpPassword="mypassword") +.. note:: + + If for some reaons you are not able to send a notification with TLS enabled and specified user name and password, you might want to use :file:`contrib/check-smtp.py` to see if it works at all. + If you want to require Transport Layer Security (TLS), then you can also set ``useTls``:: mn = status.MailNotifier(fromaddr="myuser@example.com",