I had a little bit of trouble to connect Mailgun and Digital Ocean (espacially the DNS configuration in Digital Ocean), so I’ve decided to create a little guide to help others :
## Connecting Mailgun with Digital Ocean
Activate your account (you may have to wait 5-10 minutes to receive your activation mail)
In Mailgun, do to Domains, Add a New domain. In my example I didn’t use a subdomain as they recommended, I wanted my emails to be
firstname.lastname@example.org(mine is email@example.com, you’ll see this in this guide)
In domains, you should have something like this in Domain Verification & DNS :
Now, we have to make the connection with Digital-Ocean, go to Networking > Domains
We have to setup the DNS Records, don’t follow the instructions in Mailgun :
Create a CNAME record, just put :
Create a TXT record :
"v=spf1 include:mailgun.org ~all"- The commas are recommended.
Create another TXT record :
mailo._domainkeythen the code given by Mailgun
"k=rsa; p=MIGfMA....."- Again, the commas are recommended
Here’s mine :
Go to Mailgun again and click on
Check DNS Record Now, after a few minutes, everything should be validated.
Now, you can change the email adresse you want to use (if you don’t want
postmaster@yourdomaincreated by mailgun). In Mailgun > Domains, you should have this on top of the page :
In Manage SMTP credentials make sure to set an address and a long random password of alphanumerics -
a-z, A-Z, 0-9 - you’ll need it later.
## Update your Discourse
Launch Putty or any program you use to manage your server. Use these commands :
cd /var/discourse nano containers/app.yml
In app.yml, you should have around the line 59, something like this :
## TODO: The mailserver this Discourse instance will use DISCOURSE_SMTP_ADDRESS: smtp.mailgun.org # (mandatory) DISCOURSE_SMTP_PORT: 587 # (optional) DISCOURSE_SMTP_USER_NAME: firstname.lastname@example.org # (optional) DISCOURSE_SMTP_PASSWORD: password # (optional) DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
You have to change
Exit, save the file. If you want to be sure your app.yml haven’t been messed up, you can use the YAML Validator.
We’re almost done. Now we have to rebuild the app using the command :
git pull ./launcher rebuild app
This should go fine.
Finally, in your Discourse, you can test the new mail server :
Send test email and you’re done !