RSS
 

Archive for August, 2011

Add custom SMTP Port on Zimbra

05 Aug

Some of our clients are restricted to connect to port 25 TCP by their ISP. So to give them access to our Zimbra server for sending emails, I opened another SMTP port listener (on port 587 TCP). For that, here’s the thing you will need to do.

Edit master.cf.in inside /opt/zimbra/postfix/conf/, you will see config line like below

1
smtp      inet  n       -       n       -       -       smtpd

Under that line, add the following config.

1
587      inet  n       -       n       -       -       smtpd

Done, now you can setup your mail client to use your Zimbra server with that custom 587 port instead of the standard 25. The standard 25 port will still be accessible, so technically you can use either.

 

Integrate Zimbra With Amazon SES

04 Aug

I’ve been working to integrate Zimbra with Amazon SES since the last two weeks. I finally finished that task today (yay!). Maybe some of you having the need to do the same thing, so I will try to write down what I had done to accomplished this. Just for notice, this might not the best practice, but it’s been tested to work.

Before you started, you will need to prepare Amazon SES API which you can download it here. In this example, I extracted the package and put it in /opt/SES. You will also need to install required PERL modules to be able to use it, so first make sure the script works by sending test email manually using the Amazon SES script.

After the SES script is ready, there are few configurations in Zimbra we need to change, master.cf.in and main.cf inside /opt/zimbra/postfix/conf/ and localconfig.xml inside /opt/zimbra/conf/.

First, master.cf.in. Add this line of codes at the end of the file.

1
2
aws-email unix - n n - - pipe
    flags=R user=hana argv=/opt/ses/ses-send-email.pl -r -k /opt/ses/aws-credentials.txt -e https://email.us-east-1.amazonaws.com -f ${sender} ${recipient}

Please notice the empty space at the beginning of the second line. You need to have that space or you will get a config error on restart. You can just copy paste those two lines to be safe.

Secondly, edit main.cf and add this line at the end.

1
sender_dependent_default_transport_maps = regexp:/opt/zimbra/conf/sdd_transport_maps.regexp

Now you will need to edit localconfig.xml, so you won’t loose above option added to main.cf when Zimbra restarted. Add these codes to localconfig.xml.

1
regexp:/opt/zimbra/conf/sdd_transport_maps.regexp

Now, the last thing you need to do is create the file /opt/zimbra/conf/sdd_transport_maps.regexp. As you should know, SES only accept emails from registered sender. So you need to register all of email addresses you planned to send via SES. Now we would like every sender which are registered to SES to send via SES, and the rest is send via normal SMTP sending. To be able to do so, Zimbra need to know, which addresses are suppose to be routed to SES and which aren’t. So we are gonna list all the registered addresses here inside this file (sdd_transport_maps.regexp).

The format of the file is like example below

1
2
/^hana@evilangelist\.com$/ aws-email:
/^admin@evilangelist\.com$/ aws-email:

The first part of the line is the registered email address written in regular expression, and the second part of the line is the route it suppose to be send to, in this example, “aws-email” route which we configured inside master.cf.in.

Okay, now you’re all set. Restart Zimbra and try sending email from the registered SES address. Zimbra will invoke the SES script to send it through Amazon SES. While the rest of the addresses which are not registered will be send via normal SMTP sending.

Note : Tested with Zimbra 7.1.1 RHEL5 64bit version running on 64 bit CentOS 5.6