Configure postfix to relay mails using Gmail

Install postfix

Create file

Add

Save and exit editor. Run

Edit postfix configuration file

Find and remove

At end of the file, add

Restart postfix

Now all mails will be forwarded using gmail.

Test Email Delivery

Install mailutils

To sent test email, run

Check mail log

See postfix

Configure Postfix to use Amazon SES

Install postfix with

Update postfix config with

Edit

Add to end of the file

In the above, replace SMTP_SERVER_NAME with your Amazon SES mail server, for example “email-smtp.us-east-1.amazonaws.com”, you can see it in your Amazon SES console.

Run

Replace SMTP_SERVER_NAME, SMTP_USERNAME and SMTP_PASSWORD with your actual credentials.

Now run

Restart postfix

You can test mail working with

For sending from Apache, you may need to set myorigin in postfix confgiration with your veirfied domain. This can be done by editing

You can verify myorgin with

Sending Mail from Amazon EC2

When sending email from Amazon EC2, it rejected with

Problem is solved by editing

Find

Replace with

Amazon SES

elasticemail postfix

Configure ElasticEmail with Postfix

To configure ElasticEmail with postfix, first install sasl support

On Debian/Ubuntu

On RHEL/CentOS

Edit postfix config

On Ubuntu/Debian, you need to comment the line starting with “relayhost”.

Add following

Now create file

Add following content

You can find your SMTP user name and password from

https://elasticemail.com/account/#/settings/apiconfiguration

elasticemail postfix

Now run

Restart postfix with

Postfix will relay mails using postfix now.

See postfix

Configure Postfix to sent emails using MailGun

First install requirements

Run

Edit /etc/postfix/main.cf

Add

Create file /etc/postfix/sasl_passwd

Replace SMTP_LOGIN and SMTP_PASSWORD with your user and password you get from mailgun.

Run

Restart postfix

You can test email with

SASL authentication no mechanism available

When sending email from postfix mail sever that use mailgun for relaying mails, i get error

Jan 4 03:16:06 serverok-vm postfix/qmgr[22652]: 795731A8D: from=, size=820, nrcpt=1 (queue active)
Jan 4 03:16:06 serverok-vm postfix/smtp[24050]: warning: SASL authentication failure: No worthy mechs found
Jan 4 03:16:06 serverok-vm postfix/smtp[24050]: 795731A8D: SASL authentication failed; cannot authenticate to server smtp.mailgun.org[34.237.7.101]: no mechanism available
Jan 4 03:16:06 serverok-vm postfix/smtp[24050]: warning: SASL authentication failure: No worthy mechs found
Jan 4 03:16:06 serverok-vm postfix/smtp[24050]: 795731A8D: SASL authentication failed; cannot authenticate to server smtp.mailgun.org[34.232.180.42]: no mechanism available
Jan 4 03:16:06 serverok-vm postfix/smtp[24050]: warning: SASL authentication failure: No worthy mechs found

On checking postfix mail queue, the mail is stuck in queue

The problem is fixed by installing libsasl2-modules.

On Debian/Ubuntu

On RHEL/CentOS

Now restart postfix.

postfix no local interface found

When starting postfix it failed with following error

To fix, edit /etc/postfix/main.cf

Find

Replace with

See postfix