How to Configure Postfix for External SMTP Relay

Postfix serves as a Mail Transfer Agent (MTA) designed for Unix and Linux distributions. It’s a tool used to send and receive emails.

You can configure it to specialize in sending emails, which is valuable for sending routine email notifications from your applications (projects hosted on your server).

In this tutorial, I’ll explain how to set up Postfix to send up to 1000 emails per month using a free SMTP relay service.

Why Use External SMTP Relay?

Most server providers block port 25 to prevent misuse for sending spam emails. However, you can work around this limitation by using an external SMTP relay. An external SMTP relay uses a different port, allowing you to send emails externally.

External SMTP relay means your servers don’t send emails directly. Instead, it relies on another server, often called a relay host, to send your emails for you.

External SMTP relay can assist in bypassing anti-spam blacklists. The recipient’s email server checks the relay host’s IP address because it’s the one sending the email, not your server. This means that if, for any reason, your server’s IP gets blacklisted, it won’t impact your email delivery.

Since SMTP relay services have a positive IP reputation, your emails are more likely to bypass IP blacklists and reach their destination.

Using SMTP relay services can save you time and money. Instead of dealing with a complex SMTP server that takes a lot of time to set up and maintain, why not use a reliable SMTP relay service?

When you configure Postfix to use an external SMTP relay, you can relax and be confident that your emails will be delivered without any hassle.

If I have an online shop, I need a reliable way to send important emails to my customers. These include purchase confirmations, password reset links, and welcome emails when they sign up.

These types of emails are called Transactional Emails, and they’re crucial because you always want them to reach your customers on time. Imagine not getting a password reset link promptly – that wouldn’t be ideal, right?

Info: If you’re only hosting WordPress, you can configure it to send emails via external SMTP using a plugin such as FluentSMTP.

Free 1000 Monthly Emails with SMTP2GO

Many email service providers (ESP) can serve as a relay host for Postfix. Some of these are paid, while others offer both paid plans and free plans that remain free forever.

This tutorial will use SMTP2GO, which offers a free plan allowing you to send 1000 emails per month.

I’ve been using SMTP2GO for a while now for both production and development projects, and I must say, they’re fantastic. While I won’t go into a full review, I’d like to highlight some of their excellent features.

  1. No Credit Card Needed: Unlike other ESPs, SMTP2GO doesn’t require your credit card information for signing up for their free plan.
  2. Generous Email Limit: With SMTP2GO’s free plan, you can send up to 1000 emails monthly, which is significantly more than what many other ESPs offer.
  3. User-Friendly Dashboard: Their dashboard is user-friendly and makes it easy to add a domain and set up everything you need.
  4. Exceptional Support: SMTP2GO’s support team is top-notch. They respond quickly and are willing to help with any questions, even if they’re not directly related to their services.

And, it’s worth noting that I’ve never encountered any issues with their service.

Step 1: SMTP2GO Setup

To get started, you’ll need to sign up for a free account on SMTP2GO.

Visit the website and click on Try SMTP2GO Free.

A pop-up will appear, prompting you to enter your work email address, not a shared one like or

After entering your work email, click on Continue. Next, provide your full name and create a password.

You’ll receive an activation email to confirm your email address. Open the email and follow the instructions to activate your account at SMTP2GO, completing the signup process.

After you’ve activated your account, you’ll be taken to your account dashboard, which looks like the picture below.

Now, let’s prepare everything for our Postfix setup. Click on Add a verified sender, which will open a new page where you can specify the domain from which you want to send emails, as shown in the picture below.

This domain is often the same one you use for your application, like WordPress, for example.

You have two choices: Sender domain and Single sender email. Opt for Sender domain and click on Add a sender domain.

Enter your desired domain and click Continue with this domain.

Note: Make sure your domain is active, and the email address you want to use for sending emails is working. Your domain must have the right MX, DKIM and SPF records set up to send and receive emails properly.

Next, you’ll need to configure DNS records for the domain you’re adding. SMTP2GO will automatically detect your DNS provider. In my case, it’s Cloudflare.

You’ll need to add just three CNAME records, as illustrated in the picture below.

Note: If you’re using Cloudflare, remember not to enable the proxy option.

Once the records are added, click Verify to proceed. Be patient, as it may take a few minutes for the records to take effect. After that, SMTP2GO will automatically generate an SSL certificate for your domain.

Now that your domain is verified, the final step is to add an SMTP user.

Navigate to the SMTP Users page under the Sending dropdown menu on the left-hand side and select Add SMTP user.

Choose a username and password, and if desired, provide a description, then click on Add SMTP User.

On the same page, you will also find the SMTP server information and the user you’ve just created. Keep this page open because we’ll need it later for the Postfix setup.

With this, we’ve completed the necessary setup, and we’re ready to start configuring Postfix.

Step 2: Configuring Postfix

Let’s start installing and configuring Postfix to use the SMTP2GO SMTP server as a relay host. First, we’ll install Postfix with the following command:

sudo apt install postfix libsasl2-modules

Info: The libsasl2-modules package helps with something called Simple Authentication and Security Layer (SASL), which makes sure programs can securely send emails through a relay server. It’s important when setting up Postfix as a relay host.

During the installation process, a pop-up window will appear, prompting you to select a General mail configuration type, as illustrated in the picture below. Choose the Internet Site option.

Following this, you’ll be asked to input your System mail name, which should be your domain name, as shown in the picture.

Ensure that the domain name matches the one you added to SMTP2GO.

Once you’ve done this, the installation process will continue until it’s complete.

After Postfix is installed, open the main configuration file by using the following command:

sudo vim /etc/postfix/

At the end of the file, you’ll come across a line that starts with relayhost = and has an empty value, which is the default.

In our case, this value should be set to the SMTP2GO SMTP server that we want to use as a relay host.

Remember, I mentioned earlier to keep the page open where you added your first SMTP user. You’ll find all the necessary information about their SMTP server there.

Now, set the relayhost value to, as shown below:

relayhost =

Info: SMTP2GO uses port 2525 for their SMTP server. Other ESPs use different ports, like 587. If you have trouble with port 2525, SMTP2GO has some other options to use, like 8025, 587, 80, or 25.

Next, add the following lines to the end of the file:

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:yourSMTP2GOUsername:yourSMTP2GOPassword
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
relay_destination_concurrency_limit = 20

Replace yourSMTP2GOUsername and yourSMTP2GOPassword with the SMTP user and password you created.

Here’s what each directive means:

  • smtp_sasl_auth_enable: enables SASL authentication.
  • smtp_sasl_password_maps: tells which username and password to use for SASL authentication.
  • smtp_sasl_security_options: controls the security options for SASL authentication. “noanonymous” ensures that authentication isn’t anonymous. A valid username and password must be provided to authenticate, just like the SMTP2GO SMTP user you added earlier.
  • smtp_tls_security_level: sets how safe email encryption should be. “may” means that TLS encryption is optional, and if the receiving server supports it, the connection will be encrypted.
  • header_size_limit: specifies the maximum allowed size for email headers in bytes.
  • relay_destination_concurrency_limit: decides how many connections Postfix can make to the relay destination at the same time when sending email.

Don’t forget to restart Postfix for the changes to take effect:

sudo systemctl restart postfix

By following these steps, you’ve successfully configured Postfix to use SMTP2GO SMTP server as a relay host. Congratulations!

Conclusion and Final Thoughts

And there you have it! Now you know how to configure Postfix to be a super reliable email sender using a free SMTP relay service.

I hope this tutorial has been of great help to you.

If you found value in this tutorial or have any questions or feedback, please don’t hesitate to share your thoughts in the comments section below. Your input is greatly appreciated, and you can also contact me directly if you prefer.

Remember, if you ever need assistance, you can also reach out to the friendly and knowledgeable SMTP2GO support team.


I'm excited to share my knowledge and experience! Subscribe to my newsletter for the latest updates. 👇

Leave a Reply

Your email address will not be published. Required fields are marked *