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 :
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 :
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 adresses 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 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: 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.
Rebuild the app using the command:
./launcher rebuild app`
This should go fine.
Test the new mail server
Finally, in your Discourse, you can test the new mail server :
Check this screenshot, the infos on mailgun are not made for Digital Ocean :
The first TXT with @ instead of wikidot.es (and the commas "" between v=spf1 include:mailgun.org ~all) should do the trick. I think the CNAME can only be validated if the two TXT are OK.
On the zone file you should have something like this at the end :
wikidot.es. 1800 IN TXT "v=spf1 include:mailgun.org ~all"
mailo._domainkey.wikidot.es. 1800 IN TXT "k=rsa; p=MIGf..."
email.wikidot.es. 1800 IN CNAME mailgun.org.
We don’t recommend letting DNS go to Digital Ocean. I discourage this whenever I see it, since for most people it is much simpler to control DNS from the same place they purchased the domain name from.
Sure in that case fine, but I’d be very hesitant to hand over DNS to Digital Ocean unless you have a very good reason. It’s less confusing and clearer to have your DNS handled in one place, the first place you bought the domain from, versus splitting DNS between two sources …
These are the settings recommended by Mailgun, and I have entered them in Digital Ocean. Because I am using a subdomain for discourse, I’m unsure if these are the right settings.
Hi, following your instructions and still the “k=rsa; p=MIG…” does not get verified.
Another question:
I have a droplet in digital ocean, I am pointing my domain mysite.com to my IP. In order to do the mailgun configuration I created another domain mail.mysite.com to do this setup. Is this the correct way?
If you already use your DNS provider to config some records, I think the best way is to also use it for the subdomain, it will be quicker and simpler (you just use what mailgun tells you, no need to change some things). And it will not impact your previous config
not sure if I follow you. So creating another domain (well, actually a sub-domain) in my droplet is not needed? all should be done under the mydomain.com? I thought the suggestion was to use a subdomain.mydomain.com
You can do it without creating a subdomain or using the networking panel on DigitalOcean yes.
The guide is just an alternative to link mailgun with DO instead of a DNS provider. Some people tried using DigitalOcean to do this and I wanted to help. But it’s not necessary at all