Question

How to set up mail server or SMTP account properly for Discourse?

I have been trying to set up Discourse for a few days now and I can’t find what is causing Discourse not being able to send email to the mail account I provided to be the admin. I have tried setting up Postfix, also using zoho mail (which works for my other websites), mailgun (which seems everything is okay on their website but doesn’t work when I sign up for the admin account). Am I forgetting something?

P.S. I am not really experienced about mail servers.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I was having the same problem for days, support doesn’t help, but your solution works as a charm, Thanks a lot!

What did you end up using? Did you setup Zoho for the mails? I’m having a similar issue, and have already set up the DKIM and SPF for the domain.

The discourse forum is setup in one of my sub domains in a different droplet. Do I have to set up DKIM and SPF for the sub domain as well? I tried sending test emails using Discourse but it doesn’t work.

The log message states “Sent mail to something@gmail.com (1329.1ms) Completed 422 Unprocessable Entity in 1451m”

@yanechednezzar

If there’s a connection attempt, there should be some sort of a log stating whether that attempt was successful or whether it failed (at the mail provider – either through their CP or otherwise).

Even if there’s not, there should be some sort of log, somewhere, that details what is causing mail not to go through, or causing it to fail to send.

Have you checked your error logs? You can check /var/log and run a command such as:

tail -20 /var/log/LOGFILE

Where LOGFILE is the name of the log file you wish to get output from. The above command will allow you to echo out the last 20 lines of the log. You can, of course, swap 20 out with 50, 100, etc, though normally and in most cases, the last 20 lines are enough.

Beyond that, you may wish to check and see if there’s an error log being stored for Discourse and also scan it to see if there’s something being logged. If it fails and there’s no log anywhere, that’s a major issue as something beyond mail service is probably an issue.

It could be something small, or it could be an actual issues which you’d need to report to the devs.

With that being said, how did you setup Discourse? If you’ll let me know how, I’ll run it on a tester Droplet of mine and see if I can replicate the issue.

@yanechednezzar

If you simply installed Postfix, but didn’t configure it fully or properly, about the only thing it’ll be good for out of the box is sending mail locally. External mail will almost always land in the SPAM/Junk bin (i.e. any mail sent to Google, Yahoo, [insert provider]).

When it comes to Postfix, you really need to setup a working mail server and that mail server ideally needs to be on it’s own Droplet/VPS/Dedicated, separate from applications, web-based or other.

You also really need to setup SPF, DKIM, DMARC, Black/Grey Lists, Spam and AV, etc. If that sounds like a pain, it’s because it really is. I’ve worked with Linux for over 15 years and I still dread setting up mail servers, even if the script I’m using fully automates the process. It’s the constant work required after the setup that’s where the pain points are, not really the initial setup.

That said, when it comes to using external services, such as MailGun, Zoho, etc, are you seeing any sort of error? Are you just not receiving the e-mail, is it landing in SPAM/Junk, bouncing, etc?

Even with these services (i.e. MailGun, SendGrid, etc), you still need to run through their process of setting up SPF and DKIM through their services (which is done through their control panels), else mail will still land in the SPAM/Junk bin.