diff --git a/docs/rolereference.rst b/docs/rolereference.rst index 83dc41b1463ebcc6aad3afaec2cb9c79c17292d8..136026a40c778ce1d2c87f18b06a39c9723fe1ba 100644 --- a/docs/rolereference.rst +++ b/docs/rolereference.rst @@ -733,3 +733,58 @@ Here is an example configuration for setting-up XMPP server using Prosody: smtp_allow_relay_from: - ldap.example.com - xmpp.example.com + + +Mail Forwarder +-------------- + +The ``mail_forwarder`` role can be used for setting-up a local SMTP server for +sending out mails and receiving mails for local users. The SMTP server is +provided by Postfix. + +SMTP service on server set-up this way is not meant to be exposed to the +Internet directly, and should receive delivery failures from the relay server +instead. + +The role implements the following: + +* Installs and configures Postfix. +* Purges Exim4 configuration (just in case). +* Sets-up aliases for the local recipients. + +Postfix is configured as follows: + +* Local destinations are set-up. +* A relay host is set. + + +Parameters +~~~~~~~~~~ + +**local_mail_aliases** (dictionary, mandatory) + Dictionary defining the local aliases. Aliases defined this way will either be + appended to default aliases on the server, or replace the existing entries (if + the alias/recipient is already present). Keys in the dictionary are the local + recipients/aliases, while the value provided should be a space-separated list + of mail addresses (or local users) where the mails should be forwarded. + +**smtp_relay_host** (string, mandatory) + SMTP server via which the mails are sent out for non-local recipients. + + +Examples +~~~~~~~~ + +Here is an example configuration for setting-up the mail forwarder: + +.. code-block:: yaml + + --- + + # All mails sent to local user root will be forwarded to external account as + # well. + local_mail_aliases: + root: "root john.doe@example.com" + + smtp_relay_host: mail.example.com + diff --git a/roles/mail_forwarder/templates/main.cf.j2 b/roles/mail_forwarder/templates/main.cf.j2 index fd64ecd016ef4d175d8be54cf8f0e5aa1d0bf152..75689b0f25c627edc5b17c24e56be19f8ea488ba 100644 --- a/roles/mail_forwarder/templates/main.cf.j2 +++ b/roles/mail_forwarder/templates/main.cf.j2 @@ -33,7 +33,7 @@ alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = {{ inventory_hostname }}, {{ inventory_hostname_short }}, localhost.localdomain, localhost relayhost = {{ smtp_relay_host }} -mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128{% for network in smtp_mynetworks %} {{ network }}{% endfor %} +mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_command = procmail -a "$EXTENSION" mailbox_size_limit = 0 recipient_delimiter = + diff --git a/testsite/group_vars/ldap.yml b/testsite/group_vars/ldap.yml index 793b19138abdb0c274cc1595cb12788c3e48deb6..ce1593fa43f9e9e57d405e9775b491d855b09719 100644 --- a/testsite/group_vars/ldap.yml +++ b/testsite/group_vars/ldap.yml @@ -3,9 +3,6 @@ local_mail_aliases: root: "root john.doe@example.com" -smtp_mynetworks: - - mail.example.com - smtp_relay_host: mail.example.com ldap_client_config: diff --git a/testsite/group_vars/xmpp.yml b/testsite/group_vars/xmpp.yml index 0ac44b4a7f6857cb660df38dcba5a6e9e3137716..7e912d9421b3a225c0990b03f088fad4463be5be 100644 --- a/testsite/group_vars/xmpp.yml +++ b/testsite/group_vars/xmpp.yml @@ -17,9 +17,6 @@ ldap_client_config: local_mail_aliases: root: "root john.doe@example.com" -smtp_mynetworks: - - mail.example.com - smtp_relay_host: mail.example.com prosody_administrators: