Skip to content

Commit

Permalink
Merge pull request #1628 from sa2ajj/smtp-check-script
Browse files Browse the repository at this point in the history
add a script to check smtp with starttls connectivity
  • Loading branch information
Mikhail Sobolev committed Apr 9, 2015
2 parents 892d397 + 8868f1e commit 2fec9e7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
35 changes: 35 additions & 0 deletions 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
4 changes: 4 additions & 0 deletions master/docs/manual/cfg-statustargets.rst
Expand Up @@ -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",
Expand Down

0 comments on commit 2fec9e7

Please sign in to comment.