Troubleshooting email on a new Discourse install


(Jeff Atwood) #1

You just installed Discourse via the install guide, but email doesn’t seem to work.

Unfortunately this means you can’t log in as an admin to finalize the install!

Let’s troubleshootize!


Why email error sending? Discourse does not connect to SMTP
Can't get email to send?
Test email working but activation mail not working
SMTP email configuration is not working
Test email not sending, 'completed 422 unprocessable entity' in production.log
JSON parse error when sending email with SparkPost
Email to verify new administrator not arriving
Can't get admin email to send working with using namecheap email server
User invites are not reaching destinations
Amazon SES not working with Discourse new install
What happens if you dont install email on Discourse
Discoure with Amazon ses
Logs: Job Exception
Did one-click install on Digital Ocean. Set up SMTP using SparkPost. Not receiving Discourse activation email
Need Help - Discourse New Installation Forum Mail Not Working
Discourse server failing to send email to the initial registered user
Automatic activation for users
User should be able to login without verification
Local host as domain server?
Discourse server failing to send email to the initial registered user
Confirmation Email Not Sent To User
Creating user without send out e-mail
Email confirm not sent with docker
Continue Discourse Installation
Need Help - Discourse New Installation Forum Mail Not Working
Discourse forum sometimes loads with "Index of /" sometimes correctly with its signup/ login page
Better cleanup script
Discourse Localhost User cant register (elasticemail)
E-mail didn't delivered in the easyengine(nginx) proxy mandrill environment
Mailgun test email goes to spam due to blacklist
Installing discourse and connecting it to cloudflare
Dont Get Activation Email When Signing Up
Relocation of server caused e-mail send out to fail
Fresh install on VPS can't receive email
Emails spontaneously broken
Questions about using Discourse in a small (<10 people) community
Error meanwhile upgrade from beta 5 to beta 7
Service email not woking
Is there a good information about Discourse configuration?
Error while rebuilding
Trouble configuring DNS
(Jeff Atwood) #2

Did you enter email settings correctly?

Double check the settings in your containers/app.yml file. A valid email section looks like this:

DISCOURSE_DEVELOPER_EMAILS: 'name@example.com'
DISCOURSE_SMTP_ADDRESS: smtp.mailgun.org
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: postmaster@discourse.example.com
DISCOURSE_SMTP_PASSWORD: aUd34cdWKCu6CTjfoH7ykk

Double-check all values for correctness. Note that it all aligns, there are no leading # characters, and there are single quotes around the developer email field.

If you had any errors in your app.yml and made changes , you MUST rebuild the container for those changes to take effect!

cd /var/discourse/
./launcher rebuild app

Are your SMTP connections being blocked?

To confirm that your server can indeed contact the email server, issue this command:

telnet smtp.mailgun.org 587

If you can’t connect this way, you’re almost certainly blocked. (And if you do get connected, the escape character for SMTP is ctrl+], then use quit to exit telnet.)

If this happens, contact your cloud provider support and confirm that your email connections are not being blocked.

What do the Discourse logs say?

From the command line, issue this command:

cd /var/discourse
tail shared/standalone/log/rails/production.log

This will show the last few lines of the log. Look for anything mail related. If you need to view the fuller logs, try

more shared/standalone/log/rails/production.log

To page through the complete log by pressing space. Look closely for any email related messages.

What do your email provider logs say?

Assuming there are no errors in the Discourse logs, or your Discourse mail configuration, the emails probably went out. The question, is what did your email provider do with them?

Most email providers have a log viewing function. Check the logs for your email domain and see what happened with the incoming emails.

Did you properly set up DKIM and SPF records for your domain?

You must enter those crucial DNS records for DKIM and SPF, otherwise your emails may arrive only sporadically, if at all.

Is the email domain correct?

The default email from address is based on the install domain plus subdomain, so if your URL is discourse.example.com it will be:

noreply@discourse.example.com

But if your mail provider is expecting:

noreply@example.com

… you may have problems! To get around this, edit and uncomment this line in app.yml

## If you want to set the 'From' email address for your first registration, uncomment and change:
#- exec: rails r "SiteSetting.notification_email='noreply@example.com'"
## After getting the first signup email, re-comment the line. It only needs to run once.

You’ll need to issue a rebuild after uncommenting the above line and setting the from email address as required.

You can also change this from the command line, if needed:

./launcher enter app
rails r "SiteSetting.notification_email = 'discourse@yoursite.com'"
exit

If you are using Mailgun, have you activated your domain and provided credit card information?

If you are using Mailgun, after you enter your DKIM and SPF records, you must visit https://mailgun.com/app/domains/YOUR.DISCOURSE.DOMAIN.com and click the “Check DNS Records Now” button. At the top of that page you should see “State ACTIVE” (in a calming green). If it says “State Unverified” (in a scary warning-yellow) Mailgun will not accept mail.

Mailgun now requires a credit card in order to deliver mail (other than to you). If your mailgun logs have a message about “free accounts,” this is your problem.

Other mail services have similar requirements.

Are you using an IP address as the mail domain?

This does not work in our experience. You must use a domain name when sending email, not an IP address like 192.168.1.1.

Need to log in without receiving an registration email?

We don’t recommend this, because your email is still broken, and you have a broken Discourse until email is working. But if you absolutely must log in as admin with email broken, here’s what to do:

cd /var/discourse
./launcher enter app
rake admin:create

and answer the prompts. It takes a few seconds before they appear. When it asks for the password, you will not be able to see what you type. That is why it makes you type it twice.

Email still doesn’t work! What next?

Anything else I forgot here? Feel free to edit this.


Email error. Unable to send out email
SMTP, Exchange Server problem
Email sends but isn't received
Create a unified, global setting for sender address
Emails not being sent out
No matter what I do, can't get email working on new install
Discourse installed, E-Mail problems
Following the setup instructions, so close! Error at very end!
Email to verify new administrator not arriving
Email not working after finished setting discourse
Error connecting to Redis on localhost
Test e-mail "sends" but only I (the creator of the forum) can receive it
OAuth Email missing in data explorer
How to setup relay smtp from google on discourse
Anyone using gmail for SMTP?
SMTP connection problem, docker installation
Why (many things) are as they are?
“Sidekiq is not running” Email error
"There was a problem sending the test email."
Is there a good information about Discourse configuration?
Email not received for admin verification
Gmail Smtp, mail does not come
(Anton) #114

Just a few more links on sending an email through telnet:

  1. Easy-to-follow tutorial on how to authenticate with SMTP server from telnet:
    How to Test SMTP AUTH using Telnet [Wiki] | NDCHost

  2. How to send an email from telnet:
    14.04 - How to test out the SMTP Server? - Ask Ubuntu

Followed these two and successfully sent an email with Mandrill SMTP.


(edoceo) #127

I host my own MTA via Postfix; after installing Discourse it cannot send any email through my MTA. The reason is that when Discourse connects to send it announces SMTP HELO with “localhost.localdomain” and I have Postfix configured to reject obviously bogus hostnames.

It seems that Discourse should use the hostname from what I’ve defined in the Docker configuration (forums.example.com)

But, with Postfix you can also configure the Discourse host to be more trusted by adding it to the my_networks option of Postfix - so that the invalid hostname on HELO can be ignored.


Anyone using gmail for SMTP?
(Régis Hanol) #267

I don’t think there’s a rake task, but you can run this in the rails console

Jobs::TestEmail.new.execute(to_address: "foo@bar.com")

(Anton) #291

Another option to manually check email deliverability in a more simplified way is to use Swiss Army Knife SMTP, the all-purpose smtp transaction tester (swaks) rather than telnet.

Example command:

swaks --to my@email.com --from discourse@example.com --server my.smtp.server.com --auth LOGIN --auth-user discourse@example.com -tls


(Sascha F Zeller) #305

after having read this article: Troubleshooting email on a new Discourse install I have followed all the steps mentioned, and yet the activation email is still not arriving.

I have the following entries:

DISCOURSE_DEVELOPER_EMAILS: 'sfz@dynomotion.com’
DISCOURSE_SMTP_ADDRESS: a2ss19.a2hosting.com (I have also tried mail.dynomotion.com)
DISCOURSE_SMTP_PORT: 587 (I have also tried port 2525)
DISCOURSE_SMTP_USER_NAME: sfz@discourse.dynomotion.com
DISCOURSE_SMTP_PASSWORD: MyPassword

And I uncommented the line at the end of yml.app to read like this:

- exec: rails r "SiteSetting.notification_email='sfz@dynomotion.com'"

Finally I tried this:

./launcher enter app
rails r "SiteSetting.notification_email = 'sfz@dynomotion.com'"
exit

But, like I said, no activation email.

Thank you,
Sascha


#306

this should be the web address of your SMTP mail provider, e.g. smtp.mailprovider.com

These should be the user (often “SMTP_Injection”) & secret provided by your mail provider.

You will need to set up the correct TXT entry in your sites DNS too with a key provided by your mail provider then verify it at your mail account or it won’t accept requests.


(Sascha F Zeller) #307

All values there SMTP server address, password etc.) the are correct ones - I have changed sfz@discourse.mycompany.com to sfz@mycompany.com, and it still doesn’t work. Also, uncommenting that line at the end of app.yml as suggested above did not help. I just won’t get an activation email no matter what I try…


#308

Sascha please check you have opened the port on your server to ensure the requests are allowed to get out to your mail provider.


(Sascha F Zeller) #309

OK, how do I do that?


#310

You need to modify the security settings in your cloud server account to allow SMTP inbound and outbound traffic on port 587. The interface to do this depends on your cloud provider.

NB some Cloud providers require you to send proof of ID before they will permit SMTP connectivity - this is true for e.g. Scaleway.


(Sascha F Zeller) #311

So, the cloud server running Discourse is on DigitalOcean, but my mail service is with A2 Hosting. That web server has nothing pre-installed, so I am not sure how to change any mail server settings. I did find an article on setting up a mail delivery agent:


Is that what I need to do in your opinion?


#312

No, I don’t believe so, because you are not using your DO cloud server to do the actually forwarding of email to end users. Instead you using your mail service to do this (on A2hosting apparently) - a quick search of this meta brings up little on that service provider - you might want to contact their support?

Check your log for clues:

tail shared/standalone/log/rails/production.log

A2hosting doesn’t seem to be a popular mail service on here. Are you using it successfully for emails for other websites already? Using a well known dedicated email service may improve reliability of sending emails because some IP addresses get blacklisted for mail spam, so using a well managed brand of email service that polices itself is very important.

Have you considered alternatives?

Here’s the recommended list:

Although I use:


(Sascha F Zeller) #313

We don’t really want to change our hosting company (been happy with them for a long time, our entire e-commerce website depends on the way everything is set up and as you may have guessed I’m not a developer - so I’m afraid of breaking stuff ;-).

But I will contact them to say if they can point me in the right direction.

The production log has a lot of entries like:
ActionController::RoutingError (No route matches [POST] “azenv.php”)
(No route matches [HEAD]
etc.

BTW, my outgoing SMTP port is 465.

Thank you for your time responding to my question, it’s very much appreciated!


#314

Yes, check with their support team. Make sure the mail server login details are correct, the port is correct and if required you have set up the DNS properly and verify that with your mail provider.


(Sascha F Zeller) #315

One more thing: in the example above, it states:
“Please note that in any email provider, you must verify and use the subdomain, e.g. discourse.example.com . If you verify the domain only, e.g. example.com , mail will not be configured correctly.”

I have tried that as well, but now in my app.yml I have my regular email address (without subdomain) under username and just uncommented the line toward the bottom that says:

rails r "SiteSetting.notification_email = 'sfz@dynomotion.com'"

Is that correct?


#316

I don’t have ‘discourse’ in my domain and it still works.

Mine is like : ‘noreply@mydomain.org’

But please note I have specifically set up a ‘sending domain’ with Sparkpost that is just ‘mydomain.org

This is specifically set up in a TXT record in DNS with a DKIM key Sparkpost provides and i’ve verified this domain using their website account functionality. FWIW I’ve set up the TXT record using an AWS Hosted Zone, but you could use any DNS tool …


(Sascha F Zeller) #317

I’ve been struggling with this for more than three weeks now and am afraid I have to abandon my Discourse experiment. Nothing I tried worked. My email provider has confirmed that the settings I used are correct but they never found any email attempts (activation email) from Discourse on their server…


(Tom Litchfield) #318

I feel your pain, we’ve been struggling for weeks also. We can send test emails but not activation emails. We’re resorting to hacking the core code to get emails to work.