550 Error Email Forwarding: SRS Postfix Fix
In this article
A 550 error when forwarding email usually means the receiving server rejected your forwarded message because the sender's domain failed an SPF or DMARC check. The fix is to enable Sender Rewriting Scheme (SRS) in Postfix so that the envelope sender is rewritten to your own domain before forwarding. This guide shows you how to configure SRS with Postfix, test it, and troubleshoot common problems. You will need root or sudo access to your mail server and a working Postfix installation.
What You'll Need
- Root or sudo access to your Postfix server.
- Postfix installed and running.
- Basic familiarity with editing Postfix configuration files (main.cf, master.cf).
- A domain you control with proper SPF records (optional but recommended for best results).
Step-by-Step
- Check your current Postfix version and configuration. Run
postconf -d | grep mail_versionto see the version. SRS support is not built into Postfix by default; you will need an external SRS daemon such aspostsrsd. Ensure your system can install packages (e.g., via apt or yum). - Install postsrsd. On Debian/Ubuntu:
sudo apt install postsrsd. On RHEL/CentOS:sudo yum install postsrsd. This package provides the SRS rewriting service and a Postfix map type. - Configure postsrsd. Edit
/etc/default/postsrsd(or/etc/sysconfig/postsrsdon RHEL) and setSRS_DOMAINto your mail domain (e.g.,example.com). SetSRS_SECRETto a long random string (or let it generate one). Ensure the service is enabled and started:sudo systemctl enable postsrsd && sudo systemctl start postsrsd. - Add SRS maps to Postfix main.cf. Append these lines (adjust paths if your distribution differs):
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
These tell Postfix to rewrite the envelope sender and recipient using the postsrsd service. - Reload Postfix. Run
sudo systemctl reload postfix(orpostfix reload). Check the logs (/var/log/mail.logorjournalctl -u postfix) for errors about connecting to the SRS service. - Test forwarding. Send an email from an external account (e.g., Gmail) to a forwarding address on your server that forwards to another external address. Check the headers of the forwarded message: the envelope sender should now be rewritten to something like
SRS0=...@yourdomain.com. If the recipient server accepts it, the 550 error is gone. - Verify SPF and DMARC alignment (optional but recommended). Ensure your domain's SPF record includes your server's IP. If you use DMARC, consider setting up DKIM signing for forwarded mail to improve deliverability. SRS alone fixes SPF but not DKIM; however, it is often sufficient for basic forwarding.
Common Mistakes
- Forgetting to set SRS_DOMAIN. If left as localhost, SRS rewriting will use an invalid domain and may still fail.
- Not starting postsrsd before Postfix. Postfix will fail to connect to the SRS service if it is not running. Ensure postsrsd starts automatically.
- Using the wrong map classes. Only envelope_sender and envelope_recipient should be rewritten; rewriting header addresses can break things.
- Ignoring firewall rules. postsrsd listens on localhost ports 10001 and 10002; ensure no firewall blocks localhost connections.
- Assuming SRS fixes all forwarding issues. Some receiving servers still reject based on content or other policies; SRS only addresses envelope sender rewriting.
Tips
- Keep postsrsd updated to benefit from security fixes and compatibility with newer Postfix versions.
- Monitor your mail logs for SRS-related errors; they often indicate misconfiguration.
- If you forward mail for multiple domains, set SRS_DOMAIN to a primary domain you control and ensure SPF covers it.
- Consider using a dedicated subdomain for SRS (e.g., srs.example.com) to isolate reputation.
- Test with a small set of forwarding addresses before rolling out to all users.
Troubleshooting
If forwarding still fails with a 550 error, check the following:
- Postsrsd not running: Run
systemctl status postsrsdand start it if needed. - Postfix cannot connect to SRS service: Check that postsrsd is listening on 127.0.0.1:10001 and 10002 using
netstat -tlnp | grep 1000. If not, review postsrsd configuration and restart it. - SRS_DOMAIN not set or invalid: Verify the domain in
/etc/default/postsrsdand restart postsrsd. - SPF record missing: Even with SRS, the receiving server may check SPF for your domain. Ensure your domain's SPF record authorizes your server's IP.
- Logs show "unknown service" or "connect to 127.0.0.1:10001: Connection refused": postsrsd is not running or is bound to a different address. Reinstall or reconfigure postsrsd.
- Still rejected: The remote server may have other strict policies (e.g., DMARC reject). Consider implementing DKIM signing for forwarded mail or using a mailing list manager that handles forwarding properly.
Frequently Asked Questions
What is SRS and why does it fix 550 errors?
SRS (Sender Rewriting Scheme) rewrites the envelope sender address when forwarding so that it matches your domain. This makes SPF checks pass at the receiving server, preventing 550 rejections caused by SPF failures.
Do I need to install additional software for SRS in Postfix?
Yes, Postfix does not include SRS natively. You need an external daemon like postsrsd, which integrates with Postfix via TCP maps.
Will SRS break my email forwarding in any way?
When configured correctly, SRS is transparent to users. However, some mailing lists or systems that rely on the original sender address may behave differently. Test thoroughly.
Can I use SRS with multiple domains?
Yes, but you must set a single SRS_DOMAIN that you control. All rewritten addresses will use that domain. Ensure its SPF record is correct.
What if I still get 550 errors after setting up SRS?
Check that postsrsd is running, SRS_DOMAIN is set, and your domain's SPF record includes your server. Also review mail logs for specific rejection reasons from the remote server.
Is SRS compatible with DMARC?
SRS helps with SPF alignment but does not fix DKIM alignment. For strict DMARC policies, consider adding DKIM signing to forwarded messages or using a forwarding service that preserves authentication.