Changing email SMTP From

AI-generated summary

The discussion revolves around changing the SMTP From address in Discourse to manage bounce messages effectively. rbos explains that Discourse uses the server name in the SMTP From transaction, causing bounce messages to be lost when emails are relayed to an upstream server. Despite trying the Notification Email setting, bounces still go to the upstream server. tobiaseigen asks if the issue was resolved. supermathie clarifies that the Notification Email setting affects the RFC822 From header, not the SMTP Envelope From (RFC5321), which Discourse uses reply_by_email_address for. They recommend setting reply_by_email_address to a valid address that Discourse can handle, or refer to a guide on configuring direct delivery for incoming emails.

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