Posts Tagged ‘email forwarding’

How to configure mail server forwarding on Postfix – Email forwarding from one Postfix SMTP to another

Friday, March 1st, 2013

I needed to configure mail forwarding from one Postfix mail server with a correct MX and PTR record to another one for a reason the second mail server has filtered port 25, because of ISP policy. As it is recommended in such situations, I've configured mail forwarding from postfix host1 to host2 to use (submission) port number 587 which general purpose is for exactly situations like this. Mail forwarding is done via a simple /etc/postfix/, /usr/local/etc/postfix/ (depending where Postfix is installed).

Thus as my postfix configs are in /etc/postfix, I edited /etc/postfix/ on forwarding Postfix mail server, where mail comes in (host1) and added line:

relayhost = []:587

Where is IP address of host2

To load settings I had to do the usual postfix restart

postfix# /etc/rc.d/postfix restart

postfix/postfix-script: stopping the Postfix mail system
postfix/postfix-script: starting the Postfix mail system

On host2 – to which mail is forwarded, I had to add access for host1 to relay mail  in /etc/postfix/ had to include:

mynetworks =

and is IP of host1

One note to make is if mynetworks is not defined to host of host1 mail server, you will get in /var/log/maillog error:

Relay access denied (in reply to RCPT TO command))

Here is paste chunk from /var/log/maillog

Mar  1 08:57:01 host1 postfix/smtp[95236]: 88C8B11F911:
                    to=<>, relay=[]:587, delay=0.54,
                    delays=0.01/0/0.44/0.09, dsn=5.7.1, status=bounced (host[] said: 554 5.7.1
                    <>: Relay access denied (in reply to RCPT TO command))