Email not working at all

Hello there. For the past couple of days, I’ve been struggling to setup a Discourse forum, and all the struggle came from the email. I was able to get the forum up by skipping email signup, but I still need it to be functional so people can sign up as well. I have been getting the same results again and again, and I’ve tried many different things, but none seem to have worked. Every time, one of the two would happen:

  1. Test email error would say "hostname . . . does not match the server cetificate
  2. Test email error would say “502” and in the Sidekiq, the error would be Jobs::HandledExceptionWrapper: Wrapped Net::ReadTimeout: Net::ReadTimeout with #<TCPSocket:(closed)>

So, when does each one appear. Well, number one appears in every single scenario. Number two on the other hand appeared when I used Port 465. It would take some time for it to “send a test email”, and then that error would appear. Just now, I disabled SSL, so Port 587 is usable, but instead of having the error one or two, it is just stuck at “Sending test Email”.

I am not sure what to do at this point, and I’ve been struggling with this for a few days now, and I still have not found a solution. Any help would be very much appreciated. Thank you for your time and help.

UPDATE: Using the curl --ssl-reqd command, I tested ports 465, 587, 25, and 2525. The results were:
25: Did not work (Curl error 35, wrong version number)
465: Worked as intended and fast email response
587: Did not work (Curl error 35, wrong version number)
2525: Did not fail, but never sent an email (time spent counted up and never stopped while sending no email)

If it helps, my current settings are (with the 502 error):

  DISCOURSE_SMTP_ADDRESS: CENSORED
  DISCOURSE_SMTP_PORT: 465
  DISCOURSE_SMTP_USER_NAME: CENSORED
  DISCOURSE_SMTP_PASSWORD: CENSORED
  # DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)

Templates:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"

And expose:

expose:
  - "80:80"   # http
  - "443:443" # https

This is an image with the email information:

Are you using one of the recommended email providers?

Where is the Discourse server installed?

I do not believe so. The email is provided by VoltHosting if that helps.

Also, the Discourse server is installed under var/discourse, and it does work (I can go on the website and browse around with an admin account I made (by skipping email), and that is also how I test emails (by trying to send test emails both under Email > Settings and Email > Preview Summary, which is where I get these errors. Thank you for the help though.

Try using one of the recommended providers, it will help you figure out quickly if the problem lies with your Discourse installation, or the mail server you’re attempting to communicate with.

The reason the list of recommended providers exists is because they’re validated to work with Discourse. SMTP can be painful at the best of times, and there’s a general assumption that if you’re not using the recommended setup then you assume the additional technical burden it creates.

1 Like

Thank you for the reply. I do not think I can use one of the recommended providers, since the person who made the plan has also more emails with that company, and it would be extra cost added on top of the cost for the VPS itself, and I do not think it’d be possible to do so right now. Is there maybe another way that I could more efficiently test the email services without having to rebuild the forum each time? Thank you for your help.

You don’t need to rebuild to change your email settings. You can do a:

./launcher destroy app
./launcher start app

After editing the email settings - the new ones will be picked up. The same applies to all environment variables.

Consider talking to VoltHosting for support with their email system, if their server certificate doesn’t match the hostname that’s not a Discourse problem and it’s something they need to fix. There may be an alternative hostname which you can use that is valid too.

Either way I would recommend using one of the free trials offered in the page linked above to prove that Discourse itself is handling email correctly. You can always switch back to VoltHosting SMTP once you’ve proven that Discourse itself is functioning.

Just to check, the instance was installed following this guide, correct?

1 Like

Thank you. I’ll certainly use that in the future, but I am still looking for a possible fix. If it’s any use, this a picture of the Sidekiq error:

image

I could of course use the free trials, but after all, it is a free trial, and it does have some limitations. And yes, I did follow the official guide to install the Discourse forum. It’s up and running, emails are just not working. Thank you for the help.

At this point your choices are really to test using a recommended provider, or contact VoltHosting. The errors indicate that the certificate presented by the SMTP server isn’t valid for the hostname used to connect.

Unless you can prove otherwise by testing with one of the recommended services this problem is very unlikely to be related to your Discourse installation.

That timeout error suggests that you cannot connect to your mail server. Either Digital Ocean is blocking access or something else is.

You should be able to

telnet server.hostname server-port

You likely need help from the person who set up or controlls the mail server.

1 Like

Thank you for the reply. I did ran the command just now. And these are the results:


Not sure if it supposed to let me AUTH LOGIN or not. If it is, then I would assume that is the problem, correct? Thank you for the help.

Hmm. Well, it wasn’t at the server level. My next guess is a docker networking issue. But it could be something else.

Thank you for the reply. If possible of course, how would I go into further investigation on this? Is there a docker command I could run to test it and see what it outputs, or something else? Is there any way that I can test it somewhere and it would give me an output of the problem? If not, then that is understandable as well. Thank you for the help.

UPDATE: Using the curl --ssl-reqd command, I tested ports 465, 587, 25, and 2525. The results were:
25: Did not work (Curl error 35, wrong version number)
465: Worked as intended and fast email response
587: Did not work (Curl error 35, wrong version number)
2525: Did not fail, but never sent an email (time spent counted up and never stopped while sending no email)

If it helps, my current settings are (with the 502 error):

  DISCOURSE_SMTP_ADDRESS: CENSORED
  DISCOURSE_SMTP_PORT: 465
  DISCOURSE_SMTP_USER_NAME: CENSORED
  DISCOURSE_SMTP_PASSWORD: CENSORED
  # DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)

Templates:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"

And expose:

expose:
  - "80:80"   # http
  - "443:443" # https

This is an image with the email information:


Not sure if the reason is because maybe Discourse does not connect with SSL/TLS, or something else. I hope this information is useful and will help solve the problem.

1 Like

Add this and see if it works

DISCOURSE_SMTP_ENABLE_START_TLS: False

Thank you for the reply. It sadly did not work. I am still getting the same 502 error.

Not sure if this helps, but I was able to run the curl --ssl-reqd command from the VPS and successfully sent an email (which I mentioned in this reply). Not only that, but I ran that command inside the app (entered using the ./launcher enter app), and it did work, getting the same results as the previous test (465 working, 25 and 587 not working, and 2525 giving a timeout error), yet I still get a 502 error when ran on the forum itself (using test emails). Hopefully this additional information helps. Thank you for your help.

1 Like

Did you find a solution?