FreeKB - mail module (send email)
Ansible - mail module (send email)

This assumes you have installed Ansible, are familiar with the ansible-playbook command and have created a playbook.

The mail module can be used to send email. In this example, an email will be sent to john.doe@example.com.

---
- hosts: all
  tasks:
    - mail:
        host: smtp.example.com
        port: 587
        secure: starttls
        username: your_username
        password: your_password
        from: no-reply@example.com
        to: John Doe <john.doe@example.com>
        cc: Jane Doe <jane.doe@example.com>
        subject: Example Subject
        body: 'Example Message'
      delegate_to: localhost

 

If the email is successfully sent, the play should return the following.

PLAY [all]

TASK [Gathering Facts]
ok: [server1.example.com]

TASK [mail]
ok: [server1.example.com -> localhost]

PLAY RECAP
server1.example.com   : ok=2  changed=0  unreachable=0  failed=0

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 726e8 in the box below so that we can be sure you are a human.




Comments