Email sends but isn't received


(Battlesnake) #1

I have configured email:

DISCOURSE_HOSTNAME: mydomain.com

DISCOURSE_SMTP_ADDRESS: myprovider.com
DISCOURSE_SMTP_PORT: 2525
DISCOURSE_SMTP_USER_NAME: username@mydomain.com
DISCOURSE_SMTP_PASSWORD: not_password
DISCOURSE_SMTP_ENABLE_START_TLS: true

I rebuilt the container, and the settings in the admin panel (/admin/email) match.

I enter an address to send a test email to, hit “Send Test Email” and see “Sent!”. But the email never arrives (either in Inbox or Spam).

I’ve tested with swaks:

swaks -s myprovider.com -p 2525 --ehlo mydomain.com -au username@mydomain.com -ap not_password -a PLAIN --tls --tls-verify -t myself@gmail.com -f username@mydomain.com --body "From $(hostname)"

  1. When run from my laptop, the email arrives within seconds.

  2. When run from the cloud server, the email arrives within seconds.

  3. When run from within the Discourse Docker container, the email arrives within seconds.

  4. But when I send a test email via Discourse, it doesn’t arrive. Nobody is receiving emails from the Discourse site.

For (4), here is a tail of shared/standalone/log/rails/production.log:

Started POST "/admin/email/test" for 188.222.201.238 at 2016-09-29 13:41:39 +0000
Processing by Admin::EmailController#test as */*
  Parameters: {"email_address"=>"myself@gmail.com"}

Sent mail to myself@gmail.com (378.0ms)
  Rendered text template (0.1ms)
Completed 200 OK in 535ms (Views: 1.8ms | ActiveRecord: 4.9ms)

I should add that the hostname set in the docker container does not match DISCOURSE_HOSTNAME. It is instead *-discourse, where * is the first subdomain of the full hostname name of the host machine. With TCPDUMP, I found that the EHLO command has the wrong local host name (although I doubt that this matters): EHLO localhost.localdomain

I have also reviewed the suggestions at Troubleshooting email on a new Discourse install

Info for current configuration:


(Battlesnake) #2

Solved:

After posting, I had a look in some of the other tabs, and under "Skipped", I found:
[Sender] 554 5.7.1 <myself@gmail.com>: Recipient address 
rejected: Username username@mydomain.com and sender 
noreply@mydomain.com doesnt match

I edited the notification email address in Discourse settings, and email appears to work now. Discourse was reporting that the email was sent, but it wasn’t sent successfully. I couldn’t see this from the TCPDUMP as the error message was presumably coming in via TLS and I hadn’t bothered decrypting SMTP response packets since Discourse was telling me that it was sending successfully.


(Régis Hanol) #3