Hi Samir

Please try this and make necessary changes

https://github.com/infinitypp/ansible-mail-module-examples/blob/master/tasks/main.yml


- hosts:
    - localhost
  tasks:
    - name: Sending an e-mail using Gmail SMTP servers
      mail:
        host: smtp.gmail.com
        port: 587
        username: [email protected]
        password: your-password
        to: recipient-name <recipient-email@domain>
        subject: Ansible Report
        body: System [[ ansible_hostname ]] has been successfully provisioned.
      delegate_to: localhost


On Sat, 25 Jul 2020 at 22:20, Samir Kothawade <[email protected]>
wrote:

> Yes it is. Actually I took the reference of an ansible documentation site
> for this writing above script. Here is the ref. screenshot  from ansible
> documentation.
>
> [image: image.png]
>
> On Sat, 25 Jul 2020 at 22:16, Jean-Yves LENHOF <[email protected]>
> wrote:
>
>> Look at your logs mail server(the one which answer on tcp port 25) if
>> there's something interesting in it...
>>
>> Regards,
>>
>>
>> Le 25/07/2020 à 18:43, Samir Kothawade a écrit :
>>
>> Ansible script:
>>
>> - hosts: local
>>   gather_facts: no
>>   tasks:
>>    - name: mailing longevity report
>>      become: true
>>      mail:
>>         host: localhost
>>         port: 25
>>         from: [email protected] (Longevity Report)
>>         to: Samir Kothawade <[email protected]>
>> <[email protected]>
>>         subject:  testing mail Longevity Report
>>         body: hi this is testing mail
>>
>>
>> Output observed after running above script:
>>
>>
>>
>>
>> I am not receiving emails after running above command despite if success
>> message from above script. Note -My network connectivity is good and
>> reachable to gmail as well.
>> Can someone help me out with this.
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/08204b07-6128-416c-b89d-6dcddd41f0d2o%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/08204b07-6128-416c-b89d-6dcddd41f0d2o%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/b9f7d451-9c39-5f2f-01d0-a76aeb6e2b96%40lenhof.eu.org
>> <https://groups.google.com/d/msgid/ansible-project/b9f7d451-9c39-5f2f-01d0-a76aeb6e2b96%40lenhof.eu.org?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAA%3Dr5yedn4WgwpGUiBcY__avQwGW_G2q5WrAUN2VU2Sc4Tj24Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAA%3Dr5yedn4WgwpGUiBcY__avQwGW_G2q5WrAUN2VU2Sc4Tj24Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CABAvFDMap9rBAocxHVFAURLyfwxBaduQnFeC__yEuc3Bjve%3DHg%40mail.gmail.com.

Reply via email to