How to configure Postfix with SMTP relay How to configure Postfix ...

If your ISP blocks inbound port 25 and outbound port 25, you will not be able to send out emails through standard SMTP port 25 and you need to run your server on non-standard SMTP port such as port 26, 2525 etc. to receive emails.

Our inbound SMTP relay service email store/forward can resolve the issue of ISP blocking inbound port 25. It allows you to run your email server on non-standard SMTP port such as port 2525. You will use our email servers as MX records and our email servers will receive emails for your domain name and forward the emails to your email server on port 2525.

Our outbound SMTP relay service allows you to use our email server to relay outbound emails. You will be provided a set of authentication that allows your server to log into our relay server to send emails for your domain name.

Postfix is a free and open-source mail transfer agent (MTA) that routes and delivers electronic mail, intended as an alternative to Sendmail MTA. This tutorial shows you how to configure Postfix, how to change the default SMTP port for Postfix and how to set up relay host to relay emails. If you run a Postfix server and SMTP port 25 is blocked by the ISP, this tutorial can help you bypass ISP port 25 block.

1. Install Postfix

Depending on your Linux distribution, you may use one of the following lines to install Postfix.

CentOS: yum -y install postfix
Ubuntu and Debian: sudo apt-get install postfix

2. Change SMTP port 25

By default, the SMTP protocol runs at port number 25. We assume that the ISP blocks port 25, so we will run Postfix on port 2525. To change the SMTP port number in Postfix, edit the master.cf file located in /etc/postfix directory, look for the following line:

smtp inet n - n - - smtpd
replace "smtp" with the port number that postfix should listen on, save the file and restart the postfix.

2525 inet n - n - - smtpd
/etc/init.d/postfix restart

If your ISP does not block inbound port 25, you can skip the step above.

3. Port forwarding

Port forwarding is necessary if the server is running behind a router. We need to open port 2525 on the router so that traffic is forwarded to Postfix server. Assume that the server running Postfix has an internal IP address of 192.168.0.10.

Postfix email server port forwarding
If your ISP does not block inbound port 25, you need to do port forwarding for port 25.

4. Configure Postfix

Edit the main.cf file located in /etc/postfix directory.

/etc/postfix/main.cf

myhostname = yourdomain.com
mydestination = yourdomain.com, localhost, localhost.localdomain


smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

relayhost = [relay.dynu.com]
smtp_generic_maps = hash:/etc/postfix/generic

5. Configure outbound SMTP authentication

Now we will need to create a file that host the outbound relay server username and password. Create a new document /etc/postfix/sasl_passwd .

/etc/postfix/sasl_passwd

relay.dynu.com      relay@relay.yourdomain.com: <password>

6. Reload Postfix

After you are done with the settings above and set up email accounts in /etc/postfix/generic , you need to reload Postfix.

postmap /etc/postfix/generic
postmap /etc/postfix/sasl_passwd
/etc/init.d/postfix reload

7. Test your mail service

Use the following command to send out a test email. Make sure to press Enter after each line. sendmail will read your email from standard input, and attempt to send the email when you enter a single dot (".") on a new line and press enter.

sendmail someuser@gmail.com
From: you@yourdomain.com
Subject: Test
This is test email 1
.
You should be able to receive the test email if everything has been configured properly. If you use our SMTP outbound relay service, we recommend that you refer to this tutorial to set up the appropriate SPF record and DKIM signature as well.

If you have any question regarding the setup, you can open a support ticket with us. For more information on how to set up Postfix, you can refer to Postfix site.