Setup Postfix with Mailgun for reliable E-Mail Delivery on Ubuntu
Setup Postfix with Mailgun for reliable E-Mail Delivery on Ubuntu
Date: 24-08-2020
Install Postfix:
Postfix is a mail transfer agent (MTA) which is the responsible software for delivering & receiving emails, it’s essential in order to create a complete mail server.
Step 1: Login to the server by using ssh.
As the root user, you can install postfix using below command.
# apt-get install postfix
Now enter the fully qualified domain name that you want to use for send and receive mails.
Once the FQDN set, you’ve to restart the Postfix mail server by using the below command.# service postfix restart
Step 2: Signup for A Free Mailgun Account.
The Mailgun is a set of powerful APIs that allow you to send, receive, and track email.
The first 10,000 emails each month via Mailgun are free – after that, it is just 50 cents for every 1,000. You can signup for an account by using the following link.
https://www.mailgun.com/
Once signed up, go to your Mailgun Control Panel.
https://mailgun.com/cp
Click on the domains tab then select the Add Domain button.
Enter your domain name and press the Create Domain button at the bottom of the form. This will create your domain in Mailgun.
Click on the Domains tab again, and then click on your new domain in the domains list. This will take you into the details page for your new domain.
Step 3: Configuring Postfix to use Mailgun as a Relay Host.
You can find your SMTP password on the domain page. This is the password we are going to need when configuring Postfix to send our email through Mailgun.
Edit the Postfix main.cf file.# nano /etc/postfix/main.cf
Add the following to the bottom of the file:relayhost = smtp.mailgun.org smtp_sasl_auth_enable = yes smtp_sasl_password_maps = static:postmaster@pheonixsolutions.com:password smtp_sasl_security_options = noanonymous
Replace:
– pheonixsolutions.com with your domain name name
– password with the password you just grabbed from the Mailgun control panel.
Save your changes and restart postfix:# service postfix restart
Your Postfix will now send all email out through Mailgun.