ansible-role-mailout/templates/nullmailer-inject.j2
2022-03-31 02:28:26 +02:00

23 lines
592 B
Django/Jinja

#!/bin/sh
{% if mail.overwrite_from_header %}
username="$(id -un 2> /dev/null || echo nobody)"
excepted=0
for excepted_user in {% for item in mail.overwrite_from_header_except_users %} {{ item|quote }} {% endfor %}; do
if [ "$username" = "$excepted_user" ]; then
excepted=1
break
fi
done
if [ "$excepted" = "0" ]; then
export NULLMAILER_NAME="${username} on $(hostname -f)"
export NULLMAILER_USER={{ mail.from.split('@')[0]|quote }}
export NULLMAILER_HOST={{ mail.from.split('@', 1)[1]|quote }}
export NULLMAILER_FLAGS=f
fi
{% endif %}
exec /usr/bin/nullmailer-inject-bin "$@"