Can't send email with certificate issue

AI-generated summary

The user kyu is experiencing issues with email setup on Discourse, specifically with a certificate error when trying to send emails through a mail server configured on a NAS with hostname smtp.myquickid.synology.me.

Initially, setting DISCOURSE_SMTP_ENABLE_START_TLS to false resulted in an error message 530 5.7.0 Must issue a STARTTLS command first. kyu suspected this was due to the certificate issue.

However, supermathie pointed out that the error message indicates the mail server is requiring a STARTTLS command to authenticate before sending mail, and not a certificate issue.

kyu discovered that using DISCOURSE_SMTP_PORT: 25 and ignoring the username and password solved the problem, but supermathie explained that this is because the SMTP port is used for mail delivery, not submission, and the mailserver is likely configured to relay mail only for specific email domains.

supermathie recommended enabling STARTTLS and either setting up Let’s Encrypt for SMTP or disabling certificate verification.

Tried to setup discourse and have issue with email setup.
I have mail.mydomain.com connected to a mail server configured in NAS with host name
smtp.myquickid.synology.me
I can send/receive mail whatever@domain.com from thunderbird

So I setup discourse app.yml as below

  DISCOURSE_SMTP_ADDRESS: smtp.myquickid.synology.me
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: admin@mydomain.com
  DISCOURSE_SMTP_PASSWORD: "plainpassword!"
  DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)
  #DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

Since I have issue with certificate, I set TLS to false however mail can’t be sent

$ tail /var/discourse/shared/standalone/log/rails/production.log shows
....
Sent mail to admin@mydomain.com (30.1ms)
Job exception: 530 5.7.0 Must issue a STARTTLS command first

I think this is caused by setting TLS to false.
Also setting the port 25 gives same thing.

I did check both

$ telnet smtp.myquickid.synology.me 25
$ telnet smtp.myquickid.synology.me 587

all work fine.

How to solve this problem?

I managed to figure this out myself.
Settings below works for my situation.

  DISCOURSE_SMTP_ADDRESS: smtp.myquickid.synology.me
  DISCOURSE_SMTP_PORT: 25
  #DISCOURSE_SMTP_USER_NAME: admin@mydomain.com
  #DISCOURSE_SMTP_PASSWORD: "plainpass"
  DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)
  #DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
  #DISCOURSE_SMTP_AUTHENTICATION: none
  DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

Ignoring user name and password is weird though.

This isn’t a certificate problem, this is the other end telling you “I won’t accept credentials over a plaintext connection, you need to use STARTTLS to connect to me and authenticate so you can send mail.”

You should enable STARTTLS and either set up Let’s Encrypt for SMTP, or just disable certificate verification.

That’s because now you’re sending to the SMTP port which is used for mail delivery not submission. Unless that mailserver is configured to relay mail for your IP, it will only accept mail for the email domains for which it is configured to accept mail.