Email redirection
This document gather possibilities of email redirection using postfix and zimbra. Please note these modifications may not survive zimbra upgrades.
Redirection based on sender address
In this example, emails send from user@domain.com will be trapped and sent to user_trapped@domain2.com. We are using check_sender_access to achieve this.
1. Enter following in the file “/opt/zimbra/conf/postfix_recipient_restrictions.cf”. Make sure it is entered at the top of the file.
vi /opt/zimbra/conf/postfix_recipient_restrictions.cf check_sender_access hash:/opt/zimbra/postfix/conf/restricted_senders
2. Create a file "/opt/zimbra/postfix/conf/restricted_senders" and list all the users, whose emails you want to redirect.
vi /opt/zimbra/postfix/conf/restricted_senders user@domain.com REDIRECT user_trapped@domain2.com user2@domain.com REDIRECT user2_trapped@zbc.com ...
3. Create the hash and restart postfix.
postmap /opt/zimbra/postfix/conf/restricted_senders zmmtactl stop zmmtactl start
Test
Login as user@domain.com and try sending email to any address. It will be redirected to user_trapped@domain2.com account and the log entry should look like this in /var/log/zimbra.log
Apr 12 10:08:34 mta postfix/smtpd[521]: NOQUEUE: redirect: RCPT from domain.com[xx.xx.xx.xx]: <user@domain.com>: Sender address triggers REDIRECT user_trapped@domain2.com; from=<user@domain.com> to=<realrecipient@domain.com> proto=ESMTP