roehling / postsrsd

Postfix Sender Rewriting Scheme daemon
324 stars 39 forks source link
email postfix srs

.. PostSRSd - Sender Rewriting Scheme daemon for Postfix Copyright 2012-2023 Timo Röhling timo@gaussglocke.de SPDX-License-Identifier: GPL-3.0-only

======== PostSRSd

Sender Rewriting Scheme daemon for Postfix

Overview

The Sender Rewriting Scheme (SRS) is a technique to forward mails from domains which deploy the Sender Policy Framework (SPF) to prohibit other Mail Transfer Agents (MTAs) from sending mails on their behalf. With SRS, an MTA can circumvent SPF restrictions by replacing the envelope sender with a temporary email address from one of their own domains. This temporary address is bound to the original sender and only valid for a certain amount of time, which prevents abuse by spammers.

Installation

Prebuilt packages


If your Linux distribution has a sufficiently recent PostSRSd package, install
it! Unless you need a specific new feature or bugfix from a newer version, it
will be much less of a maintenance burden.

If you are interested in packaging PostSRSd for a Linux distribution, have a
look at the packaging_ notes. In particular, we are currently looking for a new
Debian maintainer (`#145 <https://github.com/roehling/postsrsd/issues/145>`_).

.. _packaging: doc/packaging.rst

Building from source

Fetch the latest source tarball or clone the repository from Github_, unpack it and run::

cd path/to/source
mkdir _build && cd _build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
make -j
sudo make install

.. _Github: https://github.com/roehling/postsrsd/releases/latest

PostSRSd has a few external build dependencies:

PostSRSd relies on the FetchContent_ module of CMake for its dependency resolution. Please refer to its documentation if you wish to tweak the discovery process.

.. _CMake: https://cmake.org .. _gcc: https://gcc.gnu.org .. _pkgconf: http://pkgconf.org .. _libConfuse: https://github.com/libconfuse/libconfuse .. _sqlite3: https://sqlite.org .. _hiredis: https://github.com/redis/hiredis .. _libMilter: https://github.com/jons/libmilter .. _check: https://github.com/libcheck/check .. _FetchContent: https://cmake.org/cmake/help/latest/module/FetchContent.html .. _Python: https://www.python.org

Configuration

PostSRSd itself is configured by postsrsd.conf (see the example_ for a detailed documentation of all options). PostSRSd will look for this file in /usr/local/etc. The most important configuration options are domains (or domains-file), so PostSRSd knows about your local domains, and secrets-file with a secret passphrase for authentication. The other options often work out of the box. You can also find the example configuration installed in /usr/local/share/postsrsd. Feel free to use it as base for your own configuration.

Postfix Setup


For integration with Postfix, the recommended mechanism is via the
``canonical`` maps of the ``cleanup`` daemon. Add the following snippet to your
``/etc/postfix/main.cf``::

    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

The ``srs`` part in the lookup table mappings above is the path to the unix
socket relative to ``/var/spool/postfix``; you will have to change this if you
change the ``socketmap`` configuration of PostSRSd. If you prefer a TCP
connection, e.g. ``inet:localhost:10003``, you need to change the mapping to
something like ``socketmap:inet:localhost:10003:forward``.

.. _example: doc/postsrsd.conf

Experimental Milter Support

PostSRSd 2.x has added optional support for the Milter protocol. If you enabled it at compile time, you can set the milter option in postsrsd.conf and add the corresponding line to your etc/postfix/main.cf::

smtpd_milters = unix:srs_milter

Note that the Milter code is less tested and should be considered experimental for now and not ready for production. Feel free to report bugs or open pull requests if you try it out, though.

Migrating from version 1.x

Most configuration options can no longer be configured with command line arguments, so you will have to set them in postsrsd.conf. PostSRSd 1.x used shell variables in /etc/default/postsrsd. If you migrate your settings, you should set

Be aware that PostSRSd 2.x uses socketmap: tables, which are NOT compatible with tcp: tables. This also means that PostSRSd 2.x requires at least Postfix 2.10 now, and you need to update your Postfix configuration as detailed above.

Frequently Asked Questions