Skip to content
Oct 3 / Greg

Forwarding Your Zimbra Domains

On one of my Zimbra servers I’ve got a customer with about 8 domains. They are going to be migrating two of their domains elsewhere. While they do this, they want their old email still accessible on the old server. The problem is that if the old domains still exist on the old server and they send mail using any of the remaining domains, it will attempt to be delivered on the local old server. What we need to do is forward the domains.

I found some documentation that said you simply need to add this forwarder:

1
2
3
4
zmprov
md example.com zimbraMailCatchAllAddress @example.com
md example.com zimbraMailCatchAllForwardingAddress @example.com 
md example.com zimbraMailTransport smtp:other-mta.domain.com

This adds the forwarder to the domain itself…which should work great, right?…wrong. What this does is make adjustments to LDAP. So after applying this and testing without success I checked LDAP. The entry was there for the domain, but I found that each mailbox had its own “zimbraMailTransport” entry pointing to the local server. This user attribute was overriding my domain setting. To repair this I did the following:

First connect to your Zimbra server via LDAP. Highlight the domain you need to make the adjustment for and click on tools and export. This will spit out an LDIF file that we will be parsing.

I then used this autoit script to parse the file grabbing user accounts and editing their names into email addresses:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <file.au3>
 
$WriteMe = ""
 
Dim $aLDIF
If Not _FileReadToArray("C:\Users\Greg\Desktop\Customers\lifeagape\whatever.ldif",$aLDIF) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
For $x = 1 to $aLDIF[0]
	if StringInStr("111" & $aLDIF[$x],"dn:") > 0 Then
		;found user
		$ChangeToEmail = StringReplace($aLDIF[$x],"dn: uid=", "")
		$ChangeToEmail = StringReplace($ChangeToEmail, ",ou=people,dc=", '@')
		$ChangeToEmail = StringReplace($ChangeToEmail, ",dc=", ".")
		$WriteMe = $WriteMe & @CRLF & $ChangeToEmail
 
	EndIf
	if StringInStr("111" & $aLDIF[$x],"mail:") > 0 Then
		$WriteMe = $WriteMe & "," & StringReplace($aLDIF[$x], "mail: ", "")
	EndIf
 
	if StringInStr("111" & $aLDIF[$x],"zimbraMailAlias:") > 0 Then
		$WriteMe = $WriteMe & "," & StringReplace($aLDIF[$x], "zimbraMailAlias: ", "")
	EndIf
 
	if StringInStr("111" & $aLDIF[$x],"zimbraMailTransport:") > 0 Then
		$WriteMe = $WriteMe & "," & StringReplace($aLDIF[$x], "zimbraMailTransport: ", "")
	EndIf
 
Next
 
$fTheFile = FileOpen("C:\Users\Greg\Desktop\Customers\lifeagape\whatever.csv", 1)
 
; Check if file opened for writing OK
If $fTheFile = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
 
FileWriteLine($fTheFile, $WriteMe)
 
FileClose($fTheFile)

Last I used notepad++ to modify the desired records to look like this:

1
zmprov ma example@emailaddr.com zimbraMailTransport smtp:newlocation.mxrecord.net
Leave a Comment

*