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
Sign up on Mailgun
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 noreply@mydomain.com
(mine is noreply@iunctis.fr, 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 : email
// mailgun.org.
Create a TXT record : @
// "v=spf1 include:mailgun.org ~all"
- The commas are recommended.
Create another TXT record : mailo._domainkey
then 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@yourdomain
created by mailgun). In Mailgun > Domains, you should have this on top of the page :
In Manager SMTP credentials You can use the address and password you want. You're gonna need them.
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: noreply@yourdomaine.com # (optional)
DISCOURSE_SMTP_PASSWORD: password # (optional)
DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
You have to change DISCOURSE_SMTP_USER_NAME
and DISCOURSE_SMTP_PASSWORD
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 !