email.yml
*email.yml*
---
- hosts: localhost
tasks:
- name: sending mail
mail:
host: "smtp.gmail.com"
port: 25
username: "xxxxxxxxxxxxxx@gmail.com"
password: "xxxxxxxxxxxxx"
to: "xxxxxxxxxxxxxxxx@gmail.com"
subject: "Ansible-report"
body: "Hello, this is an e-mail. I hope you like it ;-)"This code is fine...but im getting error like this.......I tried 25,465.587
ports
According to the example in the documentation
https://docs.ansible.com/ansible/mail_module.html#examples
it's port 587.
And that's work for me.
[root@ansible-hyd ~]# ansible-playbook email.yml
PLAY [localhost]
***************************************************************TASK [setup]
*******************************************************************
ok: [localhost]TASK [sending mail]
************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg":
"Failed to send mail to server smtp.gmail.com on port 25: [Errno 101]
Network is unreachable", "rc": 1}
Do you get the same message with port 587?
If so, are port 587 open for outgoing connections?