|
|
@ -188,10 +188,14 @@ def main():
|
|
|
|
if not body:
|
|
|
|
if not body:
|
|
|
|
body = subject
|
|
|
|
body = subject
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
smtp = smtplib.SMTP_SSL(host, port=int(port))
|
|
|
|
smtp = smtplib.SMTP_SSL(host, port=int(port))
|
|
|
|
except (smtplib.SMTPException, ssl.SSLError):
|
|
|
|
except (smtplib.SMTPException, ssl.SSLError):
|
|
|
|
smtp = smtplib.SMTP(host, port=int(port))
|
|
|
|
smtp = smtplib.SMTP(host, port=int(port))
|
|
|
|
|
|
|
|
except Exception, e:
|
|
|
|
|
|
|
|
module.fail_json(rc=1, msg='Failed to send mail to server %s on port %s: %s' % (host, port, e))
|
|
|
|
|
|
|
|
|
|
|
|
smtp.ehlo()
|
|
|
|
smtp.ehlo()
|
|
|
|
if username and password:
|
|
|
|
if username and password:
|
|
|
|
if smtp.has_extn('STARTTLS'):
|
|
|
|
if smtp.has_extn('STARTTLS'):
|
|
|
|