# Sent Email with HIgh Importance

**URL:** <https://forum.ansible.com/t/sent-email-with-high-importance/7870>\
**Category:** Get Help\
**Tags:** collections\
**Created:** [August 15, 2024, 12:11pm UTC](https://forum.ansible.com/t/sent-email-with-high-importance/7870 "2024-08-15T12:11:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellboy8171](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hellboy8171/32/4472_2.png) [@hellboy8171](https://forum.ansible.com/u/hellboy8171)\
**Post date:** [August 15, 2024, 12:11pm UTC](https://forum.ansible.com/t/sent-email-with-high-importance/7870/1 "2024-08-15T12:11:28Z")

</div>

I was trying to send an email with high importance using **community.general.mail** , below is the script that I’m using.  
but these are getting skipped. IDK why. If any one have worked with it please help.

```auto
- hosts: localhost
  gather_facts: no
  vars:
      in_to:
          - "dummy1@outlook.com"
      in_cc: 
          - "dummy2@outlook.com"
  tasks:
    - block:  
          - name: Sending an e-mail when the compatibility check fails
            mail:
                host: "smtp-mail.outlook.com"
                port: "587"
                username: "user@outlook.com"
                password: "PASSWORD"
                from: "user@outlook.com"
                to: "{{ in_to | join(',') }}"
                cc: "{{ in_cc | join(',') }}"
                subject: Compatibility check Failed
                headers:
                   - X-Priority: "1"         
                   - X-MSMail-Priority: "High"
                   - Importance: "High"       
                body: "Please do the necessary validations involved."
      rescue:
              - debug:
                  msg: "Error in Sending Email"

```

```auto
PLAY [localhost] **************************************************************************************************************

TASK [Sending an e-mail when the compatibility check fails] *******************************************************************
[WARNING]: Skipping header '{'X-Priority': '1'}', unable to parse
[WARNING]: Skipping header '{'X-MSMail-Priority': 'High'}', unable to parse
[WARNING]: Skipping header '{'Importance': 'High'}', unable to parse
ok: [localhost]

```

---

<div class="post-metadata">

**Author:** ![jpmens](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jpmens/32/5543_2.png) [@jpmens](https://forum.ansible.com/u/jpmens)\
**Post date:** [August 15, 2024, 1:35pm UTC](https://forum.ansible.com/t/sent-email-with-high-importance/7870/2 "2024-08-15T13:35:13Z")

</div>

The documentation of `mail` states:

> A list of headers which should be added to the message. Each individual header is specified as `header=value`

It also points to an example in the same document:

```auto
    headers:
    - Reply-To=john@example.com
    - X-Special="Something or other"

```

---

<div class="post-metadata">

**Author:** ![hellboy8171](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hellboy8171/32/4472_2.png) [@hellboy8171](https://forum.ansible.com/u/hellboy8171)\
**Post date:** [August 15, 2024, 2:11pm UTC](https://forum.ansible.com/t/sent-email-with-high-importance/7870/4 "2024-08-15T14:11:05Z")

</div>

thanks @jpmens for correcting me here.  
althogh, now I have made the changes in the script and its working without missing the headers, but still, I’m not getting mails marked as HIGH IMPORTANCE.

```auto
[devuser@controlnode ~]$ ansible-playbook send_email.yml 

PLAY [localhost] *********************************************************************************************************

TASK [Sending an e-mail when the compatibility check fails] **************************************************************
ok: [localhost]

PLAY RECAP ***************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   

```

**EDIT:** It worked. I have to pass only one header inside headers Parameter. Thanks for the help. @jpmens
