ansible email and template

43 views
Skip to first unread message

Mahesh Nalavade

unread,
Oct 20, 2021, 2:26:50 PM10/20/21
to Ansible Project
Hi All,

I am trying to send email in html but email body display the same html file.

Playbook:
---
- name: Sending an e-mail
  mail:
    host: XXXXX
    port: 25
    from: XXXXXX
    to: "{{ to }}"
    subject: Reports
    attach: "{{ attach }}"
    body:
      <h1>Hi,</h1>
      <p style="color:red">Hope you are doing well.</p>
      <strong>Thanks,</strong>
      <p style="color:green">XXXX</p>

PFA screenshot.mail_module.jpg

Matt Martz

unread,
Oct 20, 2021, 2:30:26 PM10/20/21
to ansible...@googlegroups.com
You would need to send a multipart mime email, to allow an email client to properly render the HTML content, which the mail module provides no assistance with.

As such, you would have to build a multipart body manually in your playbook or template, which will likely require some learning and effort.

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6dd90026-20df-4a16-a8dd-8475a634f944n%40googlegroups.com.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages