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. But, wait. I see, action_mailer.smtp_settings['domain'] can be empty. So I guess
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.)