# Ansible problem with command shell : mail

**URL:** <https://forum.ansible.com/t/ansible-problem-with-command-shell-mail/31884>\
**Category:** Ansible Project\
**Created:** [December 30, 2019, 10:36am UTC](https://forum.ansible.com/t/ansible-problem-with-command-shell-mail/31884 "2019-12-30T10:36:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [December 30, 2019, 10:36am UTC](https://forum.ansible.com/t/ansible-problem-with-command-shell-mail/31884/1 "2019-12-30T10:36:33Z")

</div>

Hey !!

With prompt shell on my linux this command works perfectly :

mail -a “Content-Type: text/html” -s “Ansible deployment HospitalisV3” [moi@outlook.com](mailto:moi@outlook.com) \</home/ansible/test\_hospi\_package/frontoffice/roles/frontoffice/files/mail\_content.html

But when i use this next task, there is error with ansible :

- name: “Execut command shell with html”  
shell: mail -a “Content-Type: text/html” -s “Ansible deployment HospitalisV3” [moi@outlook.com](mailto:moi@outlook.com) \</home/ansible/test\_hospi\_package/frontoffice/roles/frontoffice/files/mail\_content.html  
delegate\_to: localhost

Error is that ansible not understand **“Content-Type: text/html”**

Someone can you help me please community Ansible !!! 🙂

Best Regards,

Karther

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 30, 2019, 10:50am UTC](https://forum.ansible.com/t/ansible-problem-with-command-shell-mail/31884/2 "2019-12-30T10:50:08Z")

</div>

Try using the native mail module instead of shell:  
[https://docs.ansible.com/ansible/latest/modules/mail\_module.html](https://docs.ansible.com/ansible/latest/modules/mail_module.html)

---

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [December 30, 2019, 1:11pm UTC](https://forum.ansible.com/t/ansible-problem-with-command-shell-mail/31884/3 "2019-12-30T13:11:38Z")

</div>

Thanks for your help Dick !! 🙂

But i try this module mail and the module in documentation Ansible but it’s not works :  
The error is :

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: socket.error: [Errno 101] Network is unreachable

It’s for that i use commande mail and not module of ansible …

Thanks for your help community ansible !! 🙂

Regards,

Karther
