In this tutorial you will learn how to configure the Postfix SMTP relay from Mailjet to CentOS/RHEL. Postfix is a popular open source SMTP server. Before that, I wrote an article about how easy it was to set up a fully functional mail server on a CentOS/RHEL with Modoboa, which helped many readers to run their own mail server.
However, some readers have told me that port 25 is blocked by the hosting provider or ISP to check for spam, so they cannot send email. Vultr releases port 25 when you ask, and Hostwinds doesn’t block port 25 at all, so I recommend using the Hostwinds VPS. Some other hosting providers or ISPs, such as DigitalOcean, would refuse to release port 25.
SMTP rescue relay
You can bypass port 25 and send e-mail messages to the outside world via the SMTP relay, as it uses port 587. With SMTP Relay, your own mail server does not send emails directly to the destination address. Instead, there is an intermediate mail server, also called a smart host or repeater, that sends mail on your behalf. Your mail server communicates with the relay host on port 587, and then the relay host communicates with the recipient’s mail server on port 25.
An SMTP relay can also help you bypass anti-spam blacklists if your IP address is blacklisted for some reason. The recipient’s mail server checks the relay host’s IP address for public anti-spam blacklists instead of your server’s IP address, and since SMTP relay services have a good IP reputation, your mail can be routed via IP blacklists.
Use of Mailjet to send 200 emails per day for free
There are a number of e-mail service providers (ESPs) that can act as repeaters. Some ask for a small contribution, others offer free quotas every month. In this article I would like to show you how to use Mailjet, an email service provider that allows you to send 200 emails per day for free.
The advantage of Mailjet is that you do not have to enter your credit card details when using the free SMTP relay service. There are other ESPs that offer a free quota each month, but require credit card details. (I know how uncomfortable it can be when you don’t have a credit card.) Mailjet is also easier to set up than other ESPs.
Create an account at mailjet.com. You can then see 3 things you need to do on the dashboard.
- SMTP configuration
- Management of the sender’s address
- Setting up domain verification (SPF and DKIM)
Step 1: Installing a postfix SMTP relay on CentOS/RHEL
First install the Postfix SMTP server on CentOS/RHEL with the following command. If Postfix is already running on your server, ignore the installation of Postfix.
sudo dnf installation postfix
To use the SMTP relay, you need to install the following two packages.
install sudo dnf cyrus-sasl-plain cyrus-sasl-md5
By default, the Relayhost option is not set in Postfix, as you can see in the example :
A way out:
Relay host =
You need to get the address of the relay node from your Mailjet account. Click the Configure my SMTP button on the Mailjet control bar.
You will see the SMTP server address and the SMTP access data.
Run the following command to configure the relay server at inv3.mailjet.com:587
sudo postconf -e relayhost = in-v3.mailjet.com:587
Edit the main Postfix configuration file with a command line text editor such as Nano.
sudo nano /etc/postfix/main.cf
Scroll down to the end of the file. (In Nano this can be done by pressing Ctrl+W and then Ctrl+V). Add the following lines to the end of this file.
# configuration of the outgoing relay
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
header_limit = 4096000
Save the file and close it. To save the file in the NANO editor, press Ctrl+O and then press Enter to confirm. Press Ctrl+X to exit.
Then create the file /etc/postfix/sasl_passwd.
sudo nano /etc/postfix/sasl_passwd
Add the SMTP relay host and SMTP references to this file as shown below. Replace the api key and secret key with your real Mailjet API key and secret key.
inv3.mailjet.com:587 api key:secret key
Save the file and close it. Then create a corresponding db-hash file with the postcard.
sudo postfolder /etc/postfix/sasl_passwd
You should now have /etc/postfix/sasl_passwd.db. Restart the postfix to make the changes take effect.
sudo systemctl Restart Postfix
By default, sasl_passwd and sasl_passwd.db can be read by any user on the server. Change the resolution to 600 so that only the root directory can read and write these two files.
sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
From now on, Postfix will send the mail by mail beam.
Step 2: Addition of sender addresses
To send e-mail via mailjet, you need to add the domain or address of the sender. On the Mailjet control bar, click Manage Sender Addresses. You can check the entire domain or specific email addresses.
Step 3: Configuring Domain Authentication
At this point we need to set up SPF and DKIM registration, which is highly recommended if you want your e-mail to reach the recipient’s inbox and not the junk mail folder.
- FPS: policy framework for broadcasting. This is a DNS item that determines which IP addresses are allowed to send e-mail from your domain.
- DKIM: DomainKeys Identified Mail. Mailjet signs your e-mail with its private key. A DKIM record contains a public key with which the recipient’s mail server can verify the signature.
On the Mailjet toolbar, click the Set Domain Authentication button. By default, both the SPF and DKIM statuses are incorrect. Press the controller and follow the instructions to add SPF and DKIM.
After creating the SPF and DKIM data, wait a few minutes and update the Mailjet site. The distribution of new DNS items over the Internet can take some time, depending on the DNS hosting service. If the SPF and DKIM data are configured correctly and the distribution is complete, mailjet will tell you that the SPF and DKIM data are good.
Send a test e-mail
We can now send a test mail with the mailx command, as shown below.
install sudo dnf mailx
ultrasound, this is a test e-mail. |mailx -r from -s Hello to -s.
You can also send a trial e-mail from your web or desktop e-mail client. It would also be a good idea to test your email at https://www.mail-tester.com. As you can see, I have an excellent result.
If your email was not delivered and you found the following message in the log (/var/log/maillog),
Deny access to the relay (in response to the RCPT TO command).
you may need to change the /etc/postfix/sasl_passwd file and remove the port number after the host name as shown below.
inv3.mailjet.com api key: secret key
Save the file and close it. Then create the index file again.
sudo postfolder /etc/postfix/sasl_passwd
Restart the postfix to make the changes take effect.
sudo systemctl Restart Postfix
You can now clear the mail queue (try to deliver previous e-mails).
Maritime mail -f
Addition of additional domains
If you are setting up a mail server on a new machine for a new domain name and you want to set up an SMTP relay for this new domain name, follow the same steps :
- Configuration of SMTP relay parameters
- Checking a new domain name in the Mailjet toolbar
- Configuration of the SPF and DKIM exams
Let’s go, let’s go, let’s go, let’s go! We hope this guide has helped you configure the Postfix SMTP relay on the CentOS/RHEL to bypass port 25 or IP blacklists. As always, if you find this message useful, subscribe to our free newsletter for more tips and tricks. Take care of yourself.
Evaluate this training manual.
On second thought: 0 Average : 0]centos configure sendmail smtp relay,centos smtp relay,best mail server for centos 7,postfix smtp relay mailjet,centos 8 mail server,iredmail smtp relay,how to setup a mail relay server,mailjet relay access denied