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