Postfix as email forwarder to gmail, SPF problems

I'm trying to configure postfix as forwader to gmail. I've successfully onfigured the virtual aliases for the domains I'm hosting and that I want to redirect, but the Gmail SPF verification is failing due to this:

Delivered-To: [email protected]
Received: by 10.25.28.147 with SMTP id c141csp88155lfc;
    Sat, 11 Oct 2014 09:08:40 -0700 (PDT)
X-Received: by 10.224.70.83 with SMTP id c19mr21300511qaj.66.1413043720159;
    Sat, 11 Oct 2014 09:08:40 -0700 (PDT)
Return-Path: <[email protected]>
Received: from mail1.mycompany.com (mail1.mycompany.com. [2604:xxxxxxx:b5c8])
    by mx.google.com with ESMTP id d63si16549011qgd.80.2014.10.11.09.08.39
    for <[email protected]>;
    Sat, 11 Oct 2014 09:08:40 -0700 (PDT)
Received-SPF: softfail (google.com: domain of transitioning [email protected] does not designate 2604:xxxxxxx:b5c8 as permitted sender) client-ip=2604:180:2:2cf::b5c

I think the problem lies in the return path. When doing email forwarding with another hoster (e.g. namecheap) that gets rewritten to this automatically:

Return-Path: <SRS0+BJjl=7C=gmail.com=realsender@eforward3e.registrar-servers.com>

Is there any way to perform such a rewrite in postfix? Thanks


Solution 1:

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