Thanks all, a colleague of mine pointed to the solution https://stackoverflow.com/questions/40904957/send-email-using-my-yahoo-account-error-message some mail services require 2FA and per-app passwords
now it is working! Umberto Il giorno sabato 20 ottobre 2018 22:51:43 UTC+2, Sathya Narayanan ha scritto: > > Hi Umberto, > > Just a quick thought, if you have any special character in your password, > try searching them. > > Some times -$ symbols are not valid when you pass that as a vatiable. > > I am not sure if that can fix your problem, but just a suggestion. > > On Fri, 19 Oct 2018, 8:25 pm Umberto Manferdini, <[email protected] > <javascript:>> wrote: > >> Hello, >> >> Trying to use the mail module to send emails as last task of my playbook >> >> >> >> It fails saying >> >> >> fatal: [r1 -> localhost]: FAILED! => {"changed": false, "msg": >> "Authentication to smtp.mail.yahoo.com:25 failed, please check your >> username and/or password", "rc": 1} >> >> even if i'm totally sure credentials are right >> >> >> >> As I imagine, underneath, it relies on on the smtplib python module , I >> tried to do it manually >> >> >> >> I get this >> >> >> >> >>> server = smtplib.SMTP('smtp.mail.yahoo.com', 25) >> >> >> >> >>> server.connect('smtp.mail.yahoo.com', 25) >> >> Traceback (most recent call last): >> >> File "<stdin>", line 1, in <module> >> >> File "/usr/lib/python2.7/smtplib.py", line 317, in connect >> >> (code, msg) = self.getreply() >> >> File "/usr/lib/python2.7/smtplib.py", line 368, in getreply >> >> raise SMTPServerDisconnected("Connection unexpectedly closed") >> >> smtplib.SMTPServerDisconnected: Connection unexpectedly closed >> >> >> >> >>> server.connect('smtp.mail.yahoo.com', 25) >> >> (220, 'smtp.mail.yahoo.com ESMTP ready') >> >> >> >> >>> server.ehlo() >> >> (250, 'smtp431.mail.ir2.yahoo.com Hello*** >> [***])\nPIPELINING\nENHANCEDSTATUSCODES\n8BITMIME\nSIZE 41697280\nSTARTTLS') >> >> >> >> >>> server.login("*** <javascript:>","***") >> >> Traceback (most recent call last): >> >> File "<stdin>", line 1, in <module> >> >> File "/usr/lib/python2.7/smtplib.py", line 585, in login >> >> raise SMTPException("SMTP AUTH extension not supported by server.") >> >> smtplib.SMTPException: SMTP AUTH extension not supported by server. >> >> >> >> - - I can create the object >> - - First connect fails >> - - Second is ok >> - - Ehlo is fine >> - - Login fails >> >> >> >> Same happens with other smtp servers >> >> >> >> Moreover, If I try to create the server towards port 465 it fails at step >> 1 >> >> >> >> >>> server = smtplib.SMTP('smtp.mail.yahoo.com', 465) >> >> Traceback (most recent call last): >> >> File "<stdin>", line 1, in <module> >> >> File "/usr/lib/python2.7/smtplib.py", line 256, in __init__ >> >> (code, msg) = self.connect(host, port) >> >> File "/usr/lib/python2.7/smtplib.py", line 317, in connect >> >> (code, msg) = self.getreply() >> >> File "/usr/lib/python2.7/smtplib.py", line 368, in getreply >> >> raise SMTPServerDisconnected("Connection unexpectedly closed") >> >> smtplib.SMTPServerDisconnected: Connection unexpectedly closed >> >> >> >> has anyone encountered this before? >> >> >> task is >> >> >> - name: Sending an e-mail >> mail: >> host: smtp.mail.yahoo.com >> port: 25 >> username: "***" >> password: "***" >> to: *** >> subject: Ansible-report >> body: "report generated" >> attach: >> - "sanity_report.csv" >> - "{{playbook_dir}}/outputs.tgz" >> delegate_to: localhost >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/22818f52-2dfd-427a-b25c-dc49dba84517%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ansible-project/22818f52-2dfd-427a-b25c-dc49dba84517%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b8ddec17-401b-419f-98f4-09aaa01ee5b1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
