Postfix change "From: " address when redirecting received email

Solution 1:

Preserving the From: is not a problem since SPF checks are not done against the From: header. In fact, it is a great idea not to touch the From: header since emails from @gmail.com usually have this From: header signed with DKIM.

You need to rewrite the envelope sender, which you may see in the email headers as Return-Path:. This answer provides one possible solution to your problem. To quote it here:

I fixed this with postsrsd by following this guide: https://www.mind-it.info/forward-postfix-spf-srs/

In short:

Download and compile the software

cd ~
wget https://github.com/roehling/postsrsd/archive/master.zip
unzip master
cd postsrsd-master/
make
sudo make install

Add postfix configuration parameters for postsrsd

sudo postconf -e "sender_canonical_maps = tcp:127.0.0.1:10001"
sudo postconf -e "sender_canonical_classes = envelope_sender"
sudo postconf -e "recipient_canonical_maps = tcp:127.0.0.1:10002"
sudo postconf -e "recipient_canonical_classes = envelope_recipient"

Add SRS daemon to startup

sudo chkconfig postsrsd on
# Start SRS daemon
sudo service postsrsd restart
#Reload postfix
sudo service postfix reload