Gmail.com is bouncing forwarded emails

I have figured out how to get postsrsd working, mostly thanks to the links here and a little bit of info from the github page of postsrsd.

As @pythonista2 mentions, the Vander site is slightly outdated. The main difference beween my approach and his is I used the main.cf changes from the github page.

I have written a small guide for a (so far on 3 servers tested) succesfull deployment:

  1. Check, add if not exist, spf record for the rewrite domain (in my cases the hostname of the server)
  2. In a (root) terminal execute the following commands:
mkdir /opt/postsrsd
cd /opt/postsrsd
apt -y install autotools-dev autoconf flex cmake automake
wget https://github.com/roehling/postsrsd/archive/master.zip
unzip master
cd postsrsd-main
mkdir _build && cd _build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
make -j
sudo make install
cd ~
rm -r /opt/postsrsd
  1. Backup your Postfix main.cf configuration file:
cp /etc/postfix/main.cf /etc/postfix/main.cf.srsbackup 

  1. Add the following snippet to the end of /etc/postfix/main.cf:
#Rewrite by PostSRSd
sender_canonical_maps = socketmap:unix:srs:forward
sender_canonical_classes = envelope_sender
recipient_canonical_maps = socketmap:unix:srs:reverse
recipient_canonical_classes = envelope_recipient, header_recipient
  1. To download the standard postsrsd.conf file (easiest), execute:
wget https://github.com/roehling/postsrsd/raw/refs/heads/main/doc/postsrsd.conf -O /usr/local/etc/postsrsd.conf
  1. Edit /usr/local/etc/postsrsd.conf. Comment out line 14 so it reads:
#domains = {}

and uncomment line 26. Add the file path as shown in the example, so it reads:

domains-file = "/usr/local/etc/postsrsd.domains"
  1. In webmin, make an hourly cron job, run as root, and run it after saving. Also. Don’t forget to replace server.example.com with the subdomain or hostname of the server:
echo "server.example.com" /usr/local/etc/postsrsd.domains && /usr/sbin/virtualmin list-domains --name-only >> /usr/local/etc/postsrsd.domains
  1. If all went as smooth as it did for me, enable the postsrsd service, and restart both postfix and postsrsd for good measure:
systemctl enable postsrsd.service
systemctl restart postsrsd
systemctl restart postfix

After this, I have successfully tested mailforwarding to gmail and all tests pass.

2 Likes