Discourse SMTP sends "EHLO localhost" instead of domain, breaking Google smtp-relay

@iwaffles -

Have you tried the resolution steps in this thread and the other related ones?

Add a line to your app.yml:

DISCOURSE_SMTP_DOMAIN: [your server's fqdn]

Then in /var/discourse, ./launcher rebuild app

discourse-doctor may still report failures, but test emails from within the admin console should work, and normal email flow should resume.

If that doesn’t work, please report back, because then there’s some other aspect that hasn’t been discovered yet.


I tried the rebuild and it works!

You’re right, the discourse-doctor still fails for me.

I think I restarted discourse before instead of rebuilding, which is likely why the change didn’t take effect. Thanks @Syonyk!


It seems clear that localhost is always wrong, but that most SMTP servers ignore that value, so it hasn’t mattered.

The 3 places that smtp_domain show up in https://github.com/discourse/discourse are all > 2-7 years old. I was wondering if perhaps some library just started sending localhost for some reason?

I think that the best solution, in spite of @Falco’s concerns, would be to actually fix this somewhere like

Regardless of whether the consensus is to keep sending localhost in spite of it being out of line with the RFCs, then fixing the rake task as described above is required. Oh, and I’m the one who wrote that code. :man_shrugging: But, wait. I see, action_mailer.smtp_settings['domain'] can be empty. So I guess

    Net::SMTP.start(smtp[:address], smtp[:port], 'localhost', smtp[:user_name], smtp[:password], smtp[:authentication])

should be

     Net::SMTP.start(smtp[:address], smtp[:port], smtp[:domain] || 'localhost', smtp[:user_name], smtp[:password], smtp[:authentication])

for now, at least. I think that should use the domain if one exists and use the current (but wrong?) behavior of using localhost if discourse_smtp_host isn’t defined.

I’m reluctant to add this to discourse-setup, as it’s working for nearly everyone as it is and it’s one more rather confusing question to ask. (And I’m about to add a question for notification_email, so if we’re not careful it’ll start to seem like what I remember making the Linux kernel to be like a couple decades ago.)

Maybe this is where the localhost is coming from?


Just got flagged to this issue, and can confirm the fix works. Our normally low volume instance also exploded in sidekiq, apparently from digest jobs retrying many times.

I thought Google had put in new limits on usage as the error message there is what they put out for DoS rejections.


Thanks for the report! I’ll be adding a fix for this to discourse setup shortly.


This is now:

  • Added as an example env config in all sample files

  • Asked during Discourse new install setup

  • Fixed in the discourse doctor and rake task

Thanks everyone :tada: