更改电子邮件 SMTP 发件人

Hi,

When Discourse sends email, it uses the server name in the SMTP From transaction. The problem with that, is that I relay it to an upstream server to do the actual sending, and if it fails to send, the bounce message never gets back to the server (this is fine; I don’t want Discourse to receive email). But the bounces pile up in our postmaster inbox.

Is it possible to set the SMTP From to some other hostname, so that the bounces go to a valid email address and can be handled appropriately (eg by telling the user to fix their dang email address)?

I have already tried setting the Notification Email setting in the admin panel, but the upstream server ignores that and tries to send the bounce to the upstream server it actually received the email from instead of to the From path in the actual email.

Were you able to resolve your issue? Seems you are trying to do some complicated things with Discourse.

The notification email setting is used in the From mail header (RFC822), but (as you note) for this purpose you want to set the Envelope From that’s used in the SMTP transaction (RFC5321). Discourse uses reply_by_email_address here.

The most integrated solution is to set the reply_by_email_address to something that gets delivered back to Discourse so that it automatically handles bounces. That’s what we do on our hosting platform.

I’d suggest reading through this: Configure direct-delivery incoming email for self-hosted sites with Mail-Receiver