# ansible email and template

**URL:** <https://forum.ansible.com/t/ansible-email-and-template/17681>\
**Category:** Ansible Project\
**Created:** [March 5, 2015, 5:59pm UTC](https://forum.ansible.com/t/ansible-email-and-template/17681 "2015-03-05T17:59:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antoine\_Voiry](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@Antoine\_Voiry](https://forum.ansible.com/u/Antoine_Voiry)\
**Post date:** [March 5, 2015, 5:59pm UTC](https://forum.ansible.com/t/ansible-email-and-template/17681/1 "2015-03-05T17:59:07Z")

</div>

All,  
I am trying to send email in html  
I keep getting  
TASK: [pre\_install | send email] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost → 127.0.0.1] =\> A variable inserted a new parameter into the module args. Be sure to quote variables if they contain equal signs (for example: “{{var}}”).

My commands

- name: delete temp dir  
local\_action: file path=./tmp state=absent

- name: template create dir  
local\_action: file path=./tmp state=directory

- name: template email  
local\_action: template src=…/files/email\_template.j2 dest=./tmp/email.txt

- name: send email  
local\_action: mail  
host=‘[smtp3.hp.com](http://smtp3.hp.com)’  
port=25  
subject=“EGIT IIB ENVIRONMENT SETUP”  
body=“{{ lookup(‘file’, ‘./tmp/email.txt’) }}”  
[from="antoine.voiry@gmail.com](mailto:from=%22antoine.voiry@gmail.com)"  
[to="antoine.voiry@gmail.com](mailto:to=%22antoine.voiry@gmail.com)"  
[cc="antoine.voiry@gmail.com](mailto:cc=%22antoine.voiry@gmail.com)"  
headers=“Content-type=text/html”

The ./tmp/email.tx looks as follow

| 

| Dear All,  
The environment SANDBOX will be built or re-buil t. |
| Kind Regards |

 |

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 6, 2015, 1:17pm UTC](https://forum.ansible.com/t/ansible-email-and-template/17681/2 "2015-03-06T13:17:39Z")

</div>

The html content of your body contains quotes which break the quoting that you wrap it in.

Instead of:

body=“{{ lookup(‘file’, ‘./tmp/email.txt’) }}”

Try:

body=‘{{ lookup(“file”, “./tmp/email.txt”) }}’

Which is basically switching your surrounding quotes to ’ since your body uses " throughout.
