-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mail: fixed STARTTLS module working with python 3.7.0 #47412
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,8 +264,8 @@ def main(): | |
try: | ||
if secure != 'never': | ||
try: | ||
smtp = smtplib.SMTP_SSL(host=host, timeout=timeout) | ||
code, smtpmessage = smtp.connect(host, port=port) | ||
smtp = smtplib.SMTP_SSL(host=host, port=port, timeout=timeout) | ||
code, smtpmessage = smtp.connect(host, port) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested the mail module on Ansible v2.7.1 on Python 3.7.1 and if you specify There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tpeyton, because |
||
secure_state = True | ||
except ssl.SSLError as e: | ||
if secure == 'always': | ||
|
@@ -275,8 +275,8 @@ def main(): | |
pass | ||
|
||
if not secure_state: | ||
smtp = smtplib.SMTP(timeout=timeout) | ||
code, smtpmessage = smtp.connect(host, port=port) | ||
smtp = smtplib.SMTP(host=host, port=port, timeout=timeout) | ||
code, smtpmessage = smtp.connect(host, port) | ||
|
||
except smtplib.SMTPException as e: | ||
module.fail_json(rc=1, msg='Unable to Connect %s:%s: %s' % (host, port, to_native(e)), exception=traceback.format_exc()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is strange to me: the documentation of
smtplib
says that if you pass host/port to the constructor, it'll callconnect
for you:So you're connecting to the SMTP server twice -- why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First connect is a secure layer.