How-to: Redirect Email Between Shared IMAP Folders
Environment
- UCS with Univention Mail Server (Postfix and Dovecot).
- Shared IMAP folders created in UMC as Mail folder (IMAP) objects (
mail/folder), each with its own email address. - An ordered
virtual_alias_mapslist, not aunionmap.
This procedure uses a local Postfix virtual alias to redirect newly received messages to another shared IMAP folder. It does not move existing messages or require a personal user mailbox.
The example redirects source@example.com to target@example.com. Replace both addresses with your actual addresses. The target folder must already receive mail, and it must not redirect messages back to the source.
Run all commands as root on the mail server handling incoming mail for the source address.
Step 1: Check the Alias Map Configuration
postconf virtual_alias_maps
The local hash map must precede the LDAP maps. Expected structure, abbreviated:
virtual_alias_maps = hash:/etc/postfix/virtual, ldap:...
Important: If the maps are enclosed in
unionmap:{...}, stop here. A union map combines lookup results, so this alias may deliver to both the source and target folders instead of performing a pure redirect. Do not disableunionmapindiscriminately; existing user forwarding rules may depend on it.
For the ordered map list shown above, no changes to UCR, main.cf, or virtual_mailbox_maps are required.
Step 2: Add the Virtual Alias
Back up the existing file and open it in an editor:
cp -a /etc/postfix/virtual "/etc/postfix/virtual.bak.$(date +%Y%m%d-%H%M%S)"
nano /etc/postfix/virtual
Add this entry:
source@example.com target@example.com
Keep unrelated entries unchanged. If an entry for the source address already exists, update it rather than adding a duplicate key.
Step 3: Build the Map and Reload Postfix
postmap hash:/etc/postfix/virtual
postmap -q 'source@example.com' hash:/etc/postfix/virtual
The lookup must return:
target@example.com
If the result is correct and no errors occur, check and reload Postfix:
postfix check
postfix reload
Step 4: Verify Delivery
Send a new test message with a unique subject to source@example.com.
Verify that the message appears only in the target folder. Checking the map alone does not verify delivery.
If necessary, monitor the mail log:
tail -f /var/log/mail.log
A successful delivery typically includes:
to=<target@example.com>, orig_to=<source@example.com>, ... status=sent
The visible To: header may still contain the source address. Virtual aliases rewrite the envelope recipient, not the message headers.
Rollback
Remove only the added alias entry from /etc/postfix/virtual, then rebuild the map and reload Postfix:
postmap hash:/etc/postfix/virtual
postfix reload
New messages will again be delivered to the source folder.
Notes
- Keep the source folder and its email address configured in UCS.
- Existing messages remain in their current folder. Access permissions are not transferred; users need access to the target folder.
- The alias is local to this server and is not replicated through LDAP. In multi-server installations, configure it on each server that processes the source address.
- Verified on UCS 5.2-6 with the ordered map list described above, including UCR regeneration and rollback. The UCS 5.2 default
unionmapconfiguration is outside the scope of this procedure.