- Mailgun Account
Create a Mailgun account.
Follow the guide to add your domain to the account.
Once your domain is added and verified, head over to the Domains page, select your domain, and note the Default SMTP Login and Default Password
If you want to set up a new account, click Manage SMTP Credentials, and use the account credentials later as the account username and password.
SSH into your server.
/etc/postfix/main.cf with a text editor.
Add the following lines:
##start mailgun settings smtp_sasl_auth_enable = yes smtp_sasl_password_maps = static:USERNAME:PASSWORD smtp_sasl_security_options = noanonymous smtp_tls_security_level = may smtp_tls_loglevel = 1 relayhost = [smtp.mailgun.org]:2525 ##end mailgun settings
PASSWORD with the credentials you received from mailgun.
Reload Postfix configurations:
sudo postfix reload
Test sending an email by writing a php script, or by using the emergence command line tool. (Follow this guide for more information)
In emergence shell or php script type:
\Emergence\Mailer\Mailer::send("email@example.com", "Email Subject", "Email Body", "firstname.lastname@example.org");
email@example.com with an email account that can receive emails.
firstname.lastname@example.org with an email address from your domain
Note: this account does not have to exist, or be able to receive email.
If you receive the email, you’re good to go!