How to Set Up Postfix SMTP Relay on CentOS/Rocky Linux with Sendinblue

This tutorial is going to show you how to set up Postfix SMTP relay with Sendinblue on CentOS/Rocky Linux. Postfix is a popular open-source SMTP server. Previously I wrote an article on how to easily set up a full-blown email server on CentOS/Rocky Linux with iRedMail, which helped a lot of readers run their own email servers.

However, some readers told me that port 25 is blocked by hosting provider/ISP as a way to control email spam, so they couldn’t send emails. Vultr would unblock port 25 if you ask them to, and ScalaHosting doesn’t block port 25 at all, so I recommend using ScalaHosting VPS. Some other hosting providers/ISPs like DigitalOcean would refuse to unblock port 25.

SMTP Relay To The Rescue

You can bypass port 25 and send emails via SMTP relay because it uses TCP port 587. With SMTP relay, your own email server doesn’t directly send email to the destination email address. Instead, there’s an intermediate mail server, also known as smart host or relay host, that sends emails on your behalf. Your email server communicates with the relay host on TCP port 587, then the relay host communicates with the recipient’s mail server on port 25.

SMTP relay can also help you get around anti-spam blacklists, if your IP address is blacklisted for whatever reason. The recipient’s mail server checks the relay host’s IP address against public anti-spam blacklists, instead of your server IP address and because SMTP relay services maintain good IP reputation, so your emails can get through IP blacklists.

Using Sendinblue To Send 300 Emails Per Day For Free

There are several email service providers (ESP) that can act as relay host. Some charge a little fee, some offer free quotas every month. In this article, I’d like to show you how to use Sendinblue, which is an email service provider that allows you to send 300 emails per day for free.

The nice thing about Sendinblue is that it doesn’t require you to enter your credit card details when you use the free SMTP relay service. There are other ESPs that offer free quota every month but requires you to enter credit card details. I know how frustrated it can be when you don’t have a credit card. Sendinblue is also easier to set up, compared to other ESPs.

Step 1: Create a Sendinblue Account

Create a free account at sendinblue.com. Once you complete your user profile, click the Transactional tab, you will get your SMTP settings. If there’s no SMTP settings, you need to contact Sendinblue customer service in order to activate the transactional email service.

sendinblue SMTP relay settings

Now you need to configure your Postfix SMTP server to use the Sendinblue SMTP settings.

Step 2: Set Up Postfix SMTP Relay with Sendinblue

First, let’s install Postfix SMTP server on CentOS/RHEL with the following command. If Postfix is already running on your server, then skip installing Postfix.

sudo dnf install postfix

You need to install the following two packages in order to use SMTP relay.

sudo dnf install cyrus-sasl-plain cyrus-sasl-md5

By default, the relayhost parameter in Postfix is not set, as can be seen with:

postconf relayhost

Output:

relayhost =

Run the following command to set the value of relayhost to [smtp-relay.sendinblue.com]:587.

sudo postconf -e "relayhost = [smtp-relay.sendinblue.com]:587"

Edit the Postfix main configuration file with a command-line text editor, such as Nano.

sudo nano /etc/postfix/main.cf

Scroll down the end of the file. (In Nano, you can achieve that by pressing Ctrl+W, then Ctrl+V.)  Add the following lines to the end of this file.

# outbound relay configurations
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
header_size_limit = 4096000

Save and close the file. To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.

Then create the /etc/postfix/sasl_passwd file.

sudo nano /etc/postfix/sasl_passwd

Add the SMTP relay host and SMTP credentials to this file like below. Replace smtp_username and smtp_password with your own username and password that are given by SendinBlue. Note there’s a colon between the username and password.

[smtp-relay.sendinblue.com]:587      smtp_username:smtp_password

Save and close the file. Then create the corresponding hash db file with postmap.

sudo postmap /etc/postfix/sasl_passwd

Now you should have a file /etc/postfix/sasl_passwd.db. Restart Postfix for the changes to take effect.

sudo systemctl restart postfix

By default, sasl_passwd and sasl_passwd.db file can be read by any user on the server. Change the permission to 600 so only root can read and write to these two files.

sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db

From now on, Postfix will send emails via Sendinblue.

Step 3: Add Sender Addresses

Click the drop-down menu on the upper-right corner of your Sendinblue account dashboard and select the Senders & IPs tab to add your domain and sender address.

sendinblue add senders and domains

Step 4: Set Up SPF/DKIM Authentication in SendinBlue

In this step, we need to set up SPF and DKIM record, which is strongly recommended if you want your emails to land in recipient’s inbox rather than spam folder.

  • SPF: Sender Policy Framework. This is a DNS record that specifies what IP addresses are allowed to send email for your domain.
  • DKIM: DomainKeys Identified Mail. Sendinblue will digitally sign your emails with a private key. The DKIM record contains a public key that allows recipient’s email server to verify the signature.

In your SendinBlue dashboard, click your account name on the upper-right corner, then click Senders & IPs. Select the Domains tab -> Manage -> Authenticate this domain.

sendinblue authenticate domain

A popup appears. You need to add the first 3 records for your domain.

sendinblue spf and DKIM authentication

After SPF and DKIM records are created, wait a few moments and click the RECORD ADDED. PLEASE VERIFY IT button. Depending on your DNS hosting service, your new DNS records can take some time to propagate on the Internet.

If SPF and DKIM records are set up correctly and they are verified, your domain becomes authenticated in Sendinblue.

sendinblue domain authentication

Sending Test Email

Now we can send a test email with mailx command like below.

sudo dnf install mailx

echo "this is a test email." | mailx -r from-address -s hello to-address

You can also send a test email from your webmail client or desktop mail client. It is also a good idea to test your email score at https://www.mail-tester.com. As you can see, I got a perfect score.

Testing-Email-Score-and-Placement

Troubleshooting

If your email wasn’t delivered and you found the following message in the mail log (/var/log/maillog),

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

then you might need to edit the /etc/postfix/sasl_passwd file and remove the port number after the hostname like below.

smtp-relay.sendinblue.com      smtp_username:smtp_passowrd

Save and close the file. Then build the index file again.

sudo postmap /etc/postfix/sasl_passwd

Restart Postfix for the changes to take effect.

sudo systemctl restart postfix

Now you can flush the email queue (attempt to deliver the previous emails).

sudo postqueue -f

Adding Additional Domains

If you set up a mail server on a new host for a new domain name, and you want to set up SMTP relay for this new domain name, then simply follow step 2, step 3 and step 4 again.

Wrapping Up

That’s it! I hope this tutorial helped you set up Postfix SMTP relay on CentOS/Rocky Linux to bypass port 25 or IP blacklists. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 3 Average: 5]

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here