r/postfix: Support rewriting recipient addresses
The *postfix* role will now generate configuration and a lookup table for [canonical address mapping][0] of email recipients. To configure the mapping, the `postfix_recipient_canonical_map` must be a dictionary of source-target addresses, e.g.: ```yaml postfix_recipient_canonical_map: my.bad.email@fake.test: my.real.email@example.com ``` [0]: https://www.postfix.org/ADDRESS_REWRITING_README.html#canonical
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
smtp_inet_interfaces: localhost
|
smtp_inet_interfaces: localhost
|
||||||
smtp:
|
smtp:
|
||||||
mode: direct
|
mode: direct
|
||||||
|
postfix_recipient_canonical_map: {}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
- name: rehash postfix sasl passwd table
|
- name: rehash postfix sasl passwd table
|
||||||
command: postmap /etc/postfix/sasl_passwd
|
command: postmap /etc/postfix/sasl_passwd
|
||||||
|
- name: rehash postfix recipient canonical map
|
||||||
|
command: postmap /etc/postfix/recipient_canonical
|
||||||
- name: restart postfix
|
- name: restart postfix
|
||||||
service:
|
service:
|
||||||
name=postfix
|
name=postfix
|
||||||
|
|||||||
@@ -30,6 +30,19 @@
|
|||||||
- rehash postfix sasl passwd table
|
- rehash postfix sasl passwd table
|
||||||
- reload postfix
|
- reload postfix
|
||||||
|
|
||||||
|
- name: ensure postfix recipient canonical map is configured
|
||||||
|
template:
|
||||||
|
src: canonical_map.j2
|
||||||
|
dest: /etc/postfix/recipient_canonical
|
||||||
|
mode: u=rw,go=r
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
setype: postfix_etc_t
|
||||||
|
vars:
|
||||||
|
postfix_canonical: '{{ postfix_recipient_canonical_map }}'
|
||||||
|
notify:
|
||||||
|
- rehash postfix recipient canonical map
|
||||||
|
|
||||||
- name: ensure postfix is configured
|
- name: ensure postfix is configured
|
||||||
template:
|
template:
|
||||||
src=main.cf.j2
|
src=main.cf.j2
|
||||||
|
|||||||
3
roles/postfix/templates/canonical_map.j2
Normal file
3
roles/postfix/templates/canonical_map.j2
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{% for key, value in postfix_canonical.items() %}
|
||||||
|
{{ key }} {{ value }}
|
||||||
|
{% endfor %}
|
||||||
@@ -434,6 +434,10 @@ alias_maps = hash:/etc/aliases
|
|||||||
#alias_database = dbm:/etc/mail/aliases
|
#alias_database = dbm:/etc/mail/aliases
|
||||||
alias_database = hash:/etc/aliases
|
alias_database = hash:/etc/aliases
|
||||||
#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
|
#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
|
||||||
|
{% if postfix_recipient_canonical_map %}
|
||||||
|
|
||||||
|
recipient_canonical_maps = hash:/etc/postfix/recipient_canonical
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
# ADDRESS EXTENSIONS (e.g., user+foo)
|
# ADDRESS EXTENSIONS (e.g., user+foo)
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user