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
ansible smtp mail add username and password #7213
Conversation
Why are you removing SSL in the second patch? |
Because originally it had no logic associated to it. I've added it back in with logic and included STARTTLS. Hope this is okay. |
Rather than checking the port, it may be better to do this: try: smtp = smtplib.SMTP_SSL(host, port=int(port)) if smtp.has_extn('STARTTLS'): smtp.starttls() except ssl.SSLError: smtp = smtplib.SMTP(host, port=int(port)) smtp.ehlo() if username and password: try: smtp.login(username, password) except smtplib.SMTPAuthenticationError: module.fail_json(msg="Authentication to %s:%s failed, please check your username and/or password" % (host, port)) This would require an |
ok, thanks for that, this is true. I had to tweak it since I couldn't get it to work with your example. Changed it a little bit, tested it and it seems to work fine now. |
is this okay? |
@bhcopeland yes, the only thing holding this up is it appears there's a second PR (#6667) for the same functionality, which I didn't notice until recently. We'll have to figure out which one is the better implementation, so I'll let you know. |
okay thanks. Have committed version_added as well, the benefit of this pull request is the ability to use smtp in ssl/tls and starttls. Which I need in ansible to work with our infrastructure. When sending username and password across the internet, I'd only do it securely. Although, unsecure does also work :-). |
+1 for username and password fields on mail module, either from this PR or PR #6667. ran into this yesterday |
Hi! Thanks very much for your interest in Ansible. It sincerely means a lot to us. On September 26, 2014, due to enormous levels of contribution to the project Ansible decided to reorganize module repos, making it easier We split modules from the main project off into two repos, http://github.com/ansible/ansible-modules-core and http://github.com/ansible/ansible-modules-extras If you still would like this pull request merged, we will need your help making this target the new repo. If you do not take any action, this We apologize that we are not able to make this transition happen seamlessly, though this is a one-time change and your help is greatly appreciated -- Both sets of modules will ship with Ansible, though they'll receive slightly different ticket handling. To locate where a module lives between 'core' and 'extras'
Otherwise, if this is a new module:
It may be possible to re-patriate your pull requests automatically, one user-submitted approach for advanced git users Additionally, should you need more help with this, you can ask questions on:
Thanks you very much! |
Ansible lacks smtp username and password.