From c3cf54288387b9b6cd7165f974f36bea7c396841 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 6 Mar 2018 22:44:24 +0800 Subject: mail/postfix: rename "virtual" to "virtual-aliases" --- roles/mail/tasks/main.yml | 2 +- roles/mail/templates/postfix/main.cf.j2 | 2 +- roles/mail/templates/postfix/virtual-aliases.j2 | 35 +++++++++++++++++++++ roles/mail/templates/postfix/virtual.j2 | 41 ------------------------- 4 files changed, 37 insertions(+), 43 deletions(-) create mode 100644 roles/mail/templates/postfix/virtual-aliases.j2 delete mode 100644 roles/mail/templates/postfix/virtual.j2 (limited to 'roles') diff --git a/roles/mail/tasks/main.yml b/roles/mail/tasks/main.yml index 9718db9..d33ef1f 100644 --- a/roles/mail/tasks/main.yml +++ b/roles/mail/tasks/main.yml @@ -179,7 +179,7 @@ - name: postfix - update lookup tables command: postmap /usr/local/etc/postfix/{{ item }} with_items: - - virtual + - virtual-aliases - virtual-users notify: reload-postfix tags: postfix diff --git a/roles/mail/templates/postfix/main.cf.j2 b/roles/mail/templates/postfix/main.cf.j2 index b4685c6..1126adf 100644 --- a/roles/mail/templates/postfix/main.cf.j2 +++ b/roles/mail/templates/postfix/main.cf.j2 @@ -637,7 +637,7 @@ virtual_mailbox_maps = hash:$config_directory/virtual-users # WARNING: NEVER put a virtual MAILBOX wild-card in the virtual # ALIAS file!! # -virtual_alias_maps = hash:$config_directory/virtual +virtual_alias_maps = hash:$config_directory/virtual-aliases # With delivery to a non-Postfix mailbox store for hosted domains, # the 'virtual_transport' parameter usually specifies the Postfix LMTP diff --git a/roles/mail/templates/postfix/virtual-aliases.j2 b/roles/mail/templates/postfix/virtual-aliases.j2 new file mode 100644 index 0000000..5c60ff2 --- /dev/null +++ b/roles/mail/templates/postfix/virtual-aliases.j2 @@ -0,0 +1,35 @@ +# +# /usr/local/etc/postfix/virtual-aliases +# Postfix: $virtual_alias_maps +# +# Lookup table that alias specific mail addresses or domains to other +# local or remote address. Therefore, mails for the left-hand side +# addresses (i.e., aliases) will be *forwarded* to the right-hand side +# addresses. +# +# Here, we alias all valid (receiving) mail addresses to the virtual(8) +# destinations, as listed in $virtual_mailbox_maps . +# +# Aaron LI +# + +#======# +# NOTE # Once modified this file, run "postmap" on it! +#======# + +# Alias address | Recipient for virtual(8) +# --------------------------------------------------------------------- +{% set mydomain = mail.domains[0] %} +{% for domain in mail.domains %} +# [domain: {{ domain }}] +{% for user in mail.userdb %} +# (user: {{ user.name }}) +{{ user.name }}@{{ domain }} {{ user.name }}@{{ mydomain }} +{% if user.aliases is defined %} +# aliases +{% for alias in user.aliases|default([]) %} +{{ alias }}@{{ domain }} {{ user.name }}@{{ mydomain }} +{% endfor %}{# alias #} +{% endif %}{# aliases #} +{% endfor %}{# user #} +{% endfor %}{# domain #} diff --git a/roles/mail/templates/postfix/virtual.j2 b/roles/mail/templates/postfix/virtual.j2 deleted file mode 100644 index ea72b05..0000000 --- a/roles/mail/templates/postfix/virtual.j2 +++ /dev/null @@ -1,41 +0,0 @@ -# -# /usr/local/etc/postfix/virtual -# Postfix: $virtual_alias_maps -# -# Link alias e-mail addresses to real e-mail addresses. -# -# Aaron LI -# - -#======# -# NOTE # Once modified this file, run "postmap" on it! -#======# - -# NOTE -# ---- -# Virtual alias domains are used for forwading email from an email -# address to one or more other email addresses. They cannot receive -# and save email, but only forward email somewhere else. -# The $virtual_alias_maps mapping contains forwarding (source, -# destination) of users or domains to other email addresses or entire -# domains. This maps can return multiple right-hand side -# destinations (to forward to) for one left-hand side source, therefore -# one can forward copies of an email to several recipients. -# -# Credit: https://workaround.org/ispmail/wheezy/virtual-domains -# - -# alias mail address | local address for virtual(8) delivery -# --------------------------------------------------------------------- -{% set mydomain = mail.domains[0] %} -{% for domain in mail.domains %} -# [domain: {{ domain }}] -{% for user in mail.userdb %} -# (user: {{ user.name }}) -{{ user.name }}@{{ domain }} {{ user.name }}@{{ mydomain }} -# aliases (if any) -{% for alias in user.aliases|default([]) %} -{{ alias }}@{{ domain }} {{ user.name }}@{{ mydomain }} -{% endfor %} -{% endfor %} -{% endfor %} -- cgit v1.2.2