0

I am using the following rule to forward email in .procmailrc

# in .procmailrc

* ^Subject.*something
! another@gmail.example

The filtering and forwarding part works as intended. However, the email received by another@gmail.example has my local email address as the sender. I want to the keep the original sender so that any reply goes to the original sender and not my local address. Is there any way to do this?

tripleee
  • 1,416
  • 3
  • 15
  • 24
knightrider
  • 113
  • 1
  • 4

1 Answers1

1

This seems confused on multiple accounts. Forwarding does not touch the headers at all, and any reply from a RFC-conformant client should go to the sender indicated in the headers.

In some more detail, the Reply-To: header is the primary factor which decides where the reply should go (though some email clients vigilantly ignore this standard, cough Outlook cough); secondly, the "sender" in this context usually means the From: header which is not modified by Procmail at all in this scenario. Tertiarily, there is also the Sender: header, which was used in some legacy clients to indicate that the From: header was not the true sender; some clients show this as "on behalf of". Again, this is not modified by Procmail when you forward a message.

Finally, there is the envelope sender, which is copied into the Return-Path: header at delivery time by most delivery clients. This one does get changed under forwarding. Under some circumstances, you can change it back, but you should understand the technical consequences.

Basically, the envelope sender is only used to identify where to send a bounce message. So if you forward a message and change the envelope sender, and the forwarding operation fails, the bounce message will get sent back to the original envelope sender. They have no control over your forwarding arrangement, so they have no way to troubleshoot or fix this error. In other words, you will basically be setting them up for getting some blowback spam.

Having said that, if you really wanted to, you could. The following assumes that you have the envelope sender in Return-Path: and that the configuration of the system allows you to override the envelope sender with sendmail -f. This is technically email forgery, so some sites disable this option altogether, and some others only allow it for a small subset of privileged accounts.

:0
* ^Return-Path:[    ]*<?\/[^<>]+
! -f "$MATCH" another@gmail.example

(You could technically pick apart the capturing into MATCH and refactor it into a separate recipe before the forwarding recipe. The whitespace inside [...] consists of a space and a tab, but Server Fault will render it as a sequence of spaces, so you can't just copy/paste it from here.)

tripleee
  • 1,416
  • 3
  • 15
  • 24