mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 12:44:22 -07:00
Make mail compile on python 3
This commit is contained in:
parent
95929fb79f
commit
60b6cb8305
2 changed files with 7 additions and 4 deletions
|
@ -218,7 +218,8 @@ def main():
|
||||||
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:
|
except Exception:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(rc=1, msg='Failed to send mail to server %s on port %s: %s' % (host, port, 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()
|
||||||
|
@ -283,14 +284,16 @@ def main():
|
||||||
|
|
||||||
part.add_header('Content-disposition', 'attachment', filename=os.path.basename(file))
|
part.add_header('Content-disposition', 'attachment', filename=os.path.basename(file))
|
||||||
msg.attach(part)
|
msg.attach(part)
|
||||||
except Exception, e:
|
except Exception:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(rc=1, msg="Failed to send mail: can't attach file %s: %s" % (file, e))
|
module.fail_json(rc=1, msg="Failed to send mail: can't attach file %s: %s" % (file, e))
|
||||||
|
|
||||||
composed = msg.as_string()
|
composed = msg.as_string()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
smtp.sendmail(sender_addr, set(addr_list), composed)
|
smtp.sendmail(sender_addr, set(addr_list), composed)
|
||||||
except Exception, e:
|
except Exception:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(rc=1, msg='Failed to send mail to %s: %s' % (", ".join(addr_list), e))
|
module.fail_json(rc=1, msg='Failed to send mail to %s: %s' % (", ".join(addr_list), e))
|
||||||
|
|
||||||
smtp.quit()
|
smtp.quit()
|
||||||
|
@ -299,4 +302,5 @@ def main():
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -59,4 +59,3 @@
|
||||||
/network/openvswitch_bridge.py
|
/network/openvswitch_bridge.py
|
||||||
/network/openvswitch_port.py
|
/network/openvswitch_port.py
|
||||||
/notification/jabber.py
|
/notification/jabber.py
|
||||||
/notification/mail.py
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue