Please note, with update 2023.11 this article is outdated!
After installing the 2023.11 update, launch grommunio-update update --noreboot
to fix the postfix maps.
Users using an old appliance noticed that the "Email forward" feature does not work. In old appliances, 3 configuration files for Postfix are missing.
These instructions can also be used for Debian installations, to enable the function "Email forward".
"Email forward" is a function in the Admin UI for each user in SMTP tab.
Here I present a copy and paste guide on how to populate the 3 configuration files.
First we need to check if it is really an old appliance?
ls /etc/postfix/grommunio-*.cf | sort
We see 4 files, this is a new or updated appliance.
/etc/postfix/grommunio-bcc-forwards.cf
/etc/postfix/grommunio-virtual-mailbox-alias-maps.cf
/etc/postfix/grommunio-virtual-mailbox-domains.cf
/etc/postfix/grommunio-virtual-mailbox-maps.cf
If 4 files are shown, it is a new or updated appliance, there is nothing to do, stop at this point!
If only one or 2 files are shown, follow this instruction and populate the 3 configuration files.
/etc/postfix/grommunio-virtual-mailbox-alias-maps.cf
/etc/postfix/grommunio-virtual-mailbox-domains.cf
We only see 2 configuration files, this appliance needs some manual work, see below.
Note: if 2 files are displayed, the Postfix configuration may has been completed according to these instructions: https://community.grommunio.com/d/742-postfix-unbekannte-empfanger-direkt-ablehnen, the configuration file must be replaced because the query string is now incomplete.
Instructions to create and activate the 3 configuration files
All work is carried out on the command line. The easiest way is to connect to the grommunio server with an SSH session e.g. Putty and enter the commands with copy and paste.
Please note, first check the postfix configuration with postfix check
and fix any errors before you start with the changes! It is also wise to have a backup of your system.
Because the configuration files contain credentials for the MySQL / MariaDB database, it is not so easy to just copy the files to the server, the credentials must be entered. It is convenient that the file /etc/postfix/grommunio-virtual-mailbox-domains.cf
exists and contains the correct credentials.
1. Create the 3 missing configuration files
The first step is to copy the /etc/postfix/grommunio-virtual-mailbox-domains.cf
to the additional 3 configuration files.
cp /etc/postfix/grommunio-virtual-mailbox-domains.cf /etc/postfix/grommunio-bcc-forwards.cf
cp /etc/postfix/grommunio-virtual-mailbox-domains.cf /etc/postfix/grommunio-virtual-mailbox-alias-maps.cf
cp /etc/postfix/grommunio-virtual-mailbox-domains.cf /etc/postfix/grommunio-virtual-mailbox-maps.cf
2. Patch the query strings in the 3 new configuration files.
sed -i "s/^query.*/query = SELECT destination FROM forwards WHERE username='%s' AND forward_type = 0/" "/etc/postfix/grommunio-bcc-forwards.cf"
sed -i "s/^query.*/query = SELECT mainname FROM aliases WHERE aliasname='%s' UNION select destination FROM forwards WHERE username='%s' AND forward_type = 1/" "/etc/postfix/grommunio-virtual-mailbox-alias-maps.cf"
sed -i "s/^query.*/query = SELECT 1 FROM users WHERE username='%s'/" "/etc/postfix/grommunio-virtual-mailbox-maps.cf"
3. Add the 3 new configuration files to main.cf, so postfix can use this files.
postconf -e virtual_mailbox_maps="mysql:/etc/postfix/grommunio-virtual-mailbox-maps.cf"
postconf -e virtual_alias_maps="mysql:/etc/postfix/grommunio-virtual-mailbox-alias-maps.cf"
postconf -e recipient_bcc_maps="mysql:/etc/postfix/grommunio-bcc-forwards.cf"
4. Check that there are no duplicate entries in main.cf.
grep '^recipient_bcc_maps\|^virtual_alias_map\|^virtual_mailbox_domains\|^virtual_mailbox_maps' /etc/postfix/main.cf | sort
recipient_bcc_maps = mysql:/etc/postfix/grommunio-bcc-forwards.cf
virtual_alias_maps = mysql:/etc/postfix/grommunio-virtual-mailbox-alias-maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/grommunio-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/grommunio-virtual-mailbox-maps.cf
We need to see exactly 4 lines, if we see more than 4 lines, we need to remove the duplicate entry from main.cf manually.
5. Test the postfix configuration
postfix check
If you see errors, fix this errors. Continue only if all errors are resolved!
6. Restart postfix to activate the new configuration
systemctl restart postfix
7. Setup a "Email forward", send a mail to test "Email forward" and check the log.
journalctl -f
Depending on the configuration "Redirect" or "CC" you can see the mail receipt and the delivery to the other account in case of "Redirect" and the mail receipt and the delivery to both accounts in case of "CC".
At this point, "Email forward" works as expected.
Appendix
A. "Email forward" limitation
Please note, "Email forward" is only suitable for redirecting or duplicating mails within the same recipient domain.
Sending mail to other domains like grommunio.com or similar is not possible, you will normally get an error message like this:
... dsn=5.0.0, status=bounced (host mail.xxxx.xx[nn.nn.nn.nn] said: 550 mm.mm.mm.mm is not allowed to send mail from zzzzzz.zzz (in reply to RCPT TO command))
B. For reference: content of the 3 new configuration files
To show the contents of the 3 new configuration files, use cat
to show each file.
cat /etc/postfix/grommunio-bcc-forwards.cf
user = grommunio
password = <PASSWORD>
hosts = 127.0.0.1
dbname = grommunio
query = SELECT destination FROM forwards WHERE username='%s' AND forward_type = 0
cat /etc/postfix/grommunio-virtual-mailbox-alias-maps.cf
user = grommunio
password = <PASSWORD>
hosts = 127.0.0.1
dbname = grommunio
query = SELECT mainname FROM aliases WHERE aliasname='%s' UNION select destination FROM forwards WHERE username='%s' AND forward_type = 1
cat /etc/postfix/grommunio-virtual-mailbox-maps.cf
user = grommunio
password = <PASSWORD>
hosts = 127.0.0.1
dbname = grommunio
query = SELECT 1 FROM users WHERE username='%s'
C. For reference: show additions to the main.cf file
grep "grommunio-.*\.cf" /etc/postfix/main.cf | sort
recipient_bcc_maps = mysql:/etc/postfix/grommunio-bcc-forwards.cf
virtual_alias_maps = mysql:/etc/postfix/grommunio-virtual-mailbox-alias-maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/grommunio-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/grommunio-virtual-mailbox-maps.cf
Here we see the 4 grommunio configuration files that are now active in postfix.
Enjoy grommunio!