# Mail Callback With Items

**URL:** <https://forum.ansible.com/t/mail-callback-with-items/26294>\
**Category:** Ansible Project\
**Created:** [December 14, 2017, 5:01pm UTC](https://forum.ansible.com/t/mail-callback-with-items/26294 "2017-12-14T17:01:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobby.czechova](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bobby.czechova](https://forum.ansible.com/u/bobby.czechova)\
**Post date:** [December 14, 2017, 5:01pm UTC](https://forum.ansible.com/t/mail-callback-with-items/26294/1 "2017-12-14T17:01:31Z")

</div>

Hi,

I’m running Ansible 2.4.1.0.  
I have the below but for some reason I’m not getting the expected behaviour.

Maybe I’m wrong or have assumed incorrectly?  
I’m expecting the mail callback plugin to output the fail msg.

Please can someone suggest a change or workaround?

Thank you.

`

- name: check allowed ports  
tags: ports  
fail:  
msg: “Ansible: Alert - Rogue Port {{ item }}”  
with\_items: “{{ ports\_var.stdout\_lines }}”  
failed\_when:
- “item not in ports\_lookup\_var”  
`

If I run by hand:

ansible-playbook playbooks/rpc.yml --limit=warp.???.local --tags ports

`  
TASK [check allowed ports] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [warp.???.local] (item=127.0.0.1:1196) =\> {“changed”: false, “failed”: true, “failed\_when\_result”: true, “item”: “127.0.0.1:1196”, “msg”: “Ansible: Alert - Rogue Port 127.0.0.1:1196”}  
ok: [warp.???.local] =\> (item=\*:22)  
ok: [warp.???.local] =\> (item=127.0.0.1:25)  
ok: [warp.???.local] =\> (item=127.0.0.1:8090)  
to retry, use: --limit @/home/ansible/playbooks/rpc.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
warp.gsoc.local : ok=1 changed=1 unreachable=0 failed=1  
`

The mail received:

`
