diff --git a/defaults/main.yml b/defaults/main.yml index e497ed4..e27e3c6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -307,6 +307,8 @@ galera_notify_smtp_password: "" galera_notify_smtp_port: 25 # Set to True if you need SMTP over SSL galera_notify_smtp_ssl: False +# Set to True if you need SMTP over STARTTLS +galera_notify_smtp_starttls: False # Defines if cacti monitoring should be enabled for mysql - If used. May remove later. galera_enable_cacti_monitoring: false diff --git a/templates/etc/mysql/galeranotify.py.j2 b/templates/etc/mysql/galeranotify.py.j2 index 3894af3..02886bd 100644 --- a/templates/etc/mysql/galeranotify.py.j2 +++ b/templates/etc/mysql/galeranotify.py.j2 @@ -38,6 +38,9 @@ SMTP_PORT = {{ galera_notify_smtp_port }} # Set to True if you need SMTP over SSL SMTP_SSL = {{ galera_notify_smtp_ssl }} +# Set to True if you need SMTP over TLS +SMTP_STARTTLS = {{ galera_notify_smtp_starttls }} + # Set to True if you need to authenticate to your SMTP server SMTP_AUTH = {{ galera_notify_smtp_auth }} # Fill in authorization information here if True above @@ -90,7 +93,7 @@ def main(argv): message_obj.set_index(arg) try: send_notification(MAIL_FROM, MAIL_TO, 'Galera Notification: ' + THIS_SERVER, DATE, - str(message_obj), SMTP_SERVER, SMTP_PORT, SMTP_SSL, SMTP_AUTH, + str(message_obj), SMTP_SERVER, SMTP_PORT, SMTP_SSL, SMTP_STARTTLS, SMTP_AUTH, SMTP_USERNAME, SMTP_PASSWORD) except Exception, e: print "Unable to send notification: %s" % e @@ -102,7 +105,7 @@ def main(argv): sys.exit(0) def send_notification(from_email, to_email, subject, date, message, smtp_server, - smtp_port, use_ssl, use_auth, smtp_user, smtp_pass): + smtp_port, use_ssl, use_starttls, use_auth, smtp_user, smtp_pass): msg = MIMEText(message) msg['From'] = from_email @@ -116,6 +119,9 @@ def send_notification(from_email, to_email, subject, date, message, smtp_server, else: mailer = smtplib.SMTP(smtp_server, smtp_port) + if(use_starttls): + mailer.starttls() + if(use_auth): mailer.login(smtp_user, smtp_pass)