Skip to content
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

Closed
wants to merge 8 commits into from

Conversation

bhcopeland
Copy link
Contributor

Ansible lacks smtp username and password.

@jimi-c
Copy link
Member

jimi-c commented Apr 29, 2014

Why are you removing SSL in the second patch?

@jimi-c jimi-c added P3 labels Apr 29, 2014
@bhcopeland
Copy link
Contributor Author

Because originally it had no logic associated to it. I've added it back in with logic and included STARTTLS. Hope this is okay.

@jimi-c
Copy link
Member

jimi-c commented Apr 30, 2014

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 import ssl at the top too (for the error catching).

@bhcopeland
Copy link
Contributor Author

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.

@bhcopeland
Copy link
Contributor Author

is this okay?

@jimi-c
Copy link
Member

jimi-c commented May 6, 2014

@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.

@bhcopeland
Copy link
Contributor Author

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 :-).

@mattmakai
Copy link
Contributor

+1 for username and password fields on mail module, either from this PR or PR #6667. ran into this yesterday

@mpdehaan mpdehaan added P4 and removed P3 labels Jun 1, 2014
@mpdehaan
Copy link
Contributor

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
for developers to work on the project and for us to more easily manage new contributions and tickets.

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
pull request unfortunately cannot be applied.

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 --
this will greatly improve velocity going forward.

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
has been suggested at https://gist.github.com/willthames/afbaaab0c9681ed45619

Additionally, should you need more help with this, you can ask questions on:

Thanks you very much!

@mpdehaan mpdehaan closed this Sep 29, 2014
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_pull_request labels Mar 4, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants