Discourse connects to the SMTP server but fails to send email through it

Cant get the first user registration email:

Discourse doctor says:
SMTP server connection successful.
Sending mail failed.

However:
Telnet to mail.domain.com port 587 works and EHLO mailserver command works.

How can I fix this, any help would be greatly appreciated.

You might look at the mail server logs. Whatever error it is isn’t sometime that v Discourse-doctor understands.

You’ll need to Google how to configure exim4.

From 7. The default configuration file

Freezing occurs when a bounce message encounters a permanent failure because the sender address of the original message that caused the bounce is invalid, so the bounce cannot be delivered.

My guess is that you need to change the notification email address or configure exim to use your subdomain

1 Like

Did you forget to rebuild your container?

Anyway, you can check your container by:

docker exec -it app rails c

Then, from the rails console:

[1] pry(main)>ENV

You can look at all your SMTP environmental variables easily.

2 Likes

Exim4 was tested to verify it sends and receives emails.
Discourse was rebuilt with discourse-setup, using all the correct credentials:

Hostname      : forum domainname com
Email         : user@test com
SMTP address  : mail forum domainname com
SMTP port     : 587
SMTP username : postmaster@forum domainname com
SMTP password : password

Then, discourse-doctor is run to test weather Discourse can send email from the local exim4 mail server.

Discourse-doctor says:
“SMTP server connection successful.”
“Sending mail failed.”

However, there are no errors in the exim4 log.

Why does sending mail fail?
Is this a common problem?

Notice that the SMTP address is: mail forum domainname com,
should it have “mail” at the beginning?

Discourse-doctor says that Discourse does connect to:
mail forum domainname com,
but Discourse does not send the email.

My guess is a mismatch between your forum host name and the domain name that the mail server will send for.

What is the hostname that Discourse uses to send mail?
Does it use forum.somedomain.com?
or
Does it use mail.forum.somedomain.com?

By default it is email@forum.somedomain.com as I recall.

This trips some people up because they expect it to be

email@somedomain.com