All my mails are received by my own mail server and are then forwarded to my Google account (as I am using Google Mail as my mail client). Unfortunately if you just forward mails with POSTFIX you might also forward incoming spam mails which Google does not like. It can be that Google thinks you are a spam sender and blacklist your server.
I have found this blog entry which describes a way to correctly set the envelope address of forwarded mails:
So in summary this is what I did:
# download and compile the software cd ~ wget https://github.com/roehling/postsrsd/archive/master.zip unzip master cd postsrsd-master/ make sudo make install
Then added the following lines to /etc/postfix/main.cf:
sender_canonical_maps = tcp:127.0.0.1:10001 sender_canonical_classes = envelope_sender recipient_canonical_maps = tcp:127.0.0.1:10002 recipient_canonical_classes= envelope_recipient,header_recipient
Then I started the SRS daemon and reloaded the POSTFIX configuration:
# Start SRS daemon sudo service postsrsd restart #Reload postfix sudo service postfix reload
I did not need to add the SRS daemon to startup as it seems to be automatically started already.
As I forward all mail from my server to Expurgate/Spamfence for spam checking I also neeeded to add the Expurgate servers to my SPF domain record so that Google accepts mails sent by my mail server via Expurgate to Google. This is the PSF record I am using for my domain "urspringer.de":
v=spf1 a mx a:mx.expurgate.net ip4:126.96.36.199 ip6:2a01:488:66:1000:57e6:5590:0:1 include:expurgate.net ~all
Currently it seems to look fine as Google verifies the SPF record although the mails are forwarded twice:
Return-Path: <SRS0+WJa2=BPemail@example.com> Received: from mx.expurgate.net (mx.expurgate.net. [188.8.131.52]) by mx.google.com with ESMTPS id ft4si45524597pdb.17.2014.12.27.06.00.52 for <firstname.lastname@example.org> (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 27 Dec 2014 06:00:53 -0800 (PST) Received-SPF: pass (google.com: domain of SRS0+WJa2=BPemail@example.com designates 184.108.40.206 as permitted sender) client-ip=220.127.116.11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of SRS0+WJa2=BPfirstname.lastname@example.org designates 18.104.22.168 as permitted sender) smtp.mail=SRS0+WJa2=BPemail@example.com; dkim=pass firstname.lastname@example.org
If you cannot start the service in Debain 8 and higher () you need to enable the service first with
systemctl enable postsrsd