Postfix SRS Only Forwarded Emails

From ivc wiki
Revision as of 13:11, 11 May 2022 by Ivc (talk | contribs) (Created page with "As discussed on [https://github.com/roehling/postsrsd/discussions/76 github discussions] for [https://github.com/roehling/postsrsd/ postsrsd], it is possible to only perform Sender Rewriting Scheme (SRS) on emails passing through your server destined for an external address, bases solely on the destination email address, ex. user@example.org forwards to user@gmail.com, only match and SRS process the email going to user@gmail.com. /etc/postfix/main.cf: recipient_can...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

As discussed on github discussions for postsrsd, it is possible to only perform Sender Rewriting Scheme (SRS) on emails passing through your server destined for an external address, bases solely on the destination email address, ex. user@example.org forwards to user@gmail.com, only match and SRS process the email going to user@gmail.com.

/etc/postfix/main.cf:

recipient_canonical_maps=tcp:localhost:10002
recipient_canonical_classes=envelope_recipient,header_recipient

virtual_alias_maps = hash:/etc/postfix/virtual-alias
transport_maps = hash:/etc/postfix/transport_srs

/etc/postfix/virtual-alias:

user@example.org              user@gmail.com
name@example.org              name@gmail.com
/etc/postfic/transport_srs:

user@gmail.com              smtp:[127.0.0.1]:10027
name@gmail.com              smtp:[127.0.0.1]:10027
/etc/postfix/master.cf:

cleanup-srs   unix  n       -       -       -       0       cleanup
       -o sender_canonical_maps=hash:/etc/postfix/virtual-alias,tcp:localhost:10001
       -o sender_canonical_classes=envelope_sender

127.0.0.1:10027 inet    n       -       -       -       -       smtpd
       -o cleanup_service_name=cleanup-srs
       -o smtpd_tls_security_level=none
       -o content_filter=smtp:
       # allow for system users sending email to forwarded alias destinations, ex. user@gmail.com etc
       -o smtpd_sender_restrictions=permit_mynetworks,reject
       # allow for inbound email, ex. user@example.org, which alias maps it to forward/relay outbound again, ex. user@gmail.com etc
       -o smtpd_relay_restrictions=permit_mynetworks,reject