Setup greylite as reverse SMTP proxy

In this setup, greylite responds directly to clients, and forwards the TCP connection to the server for delivery when messages are passed.

Fetch, compile, install

  1. Fetch the last greylite release.
  2. Extract the software:
    tar xjvf greylite-VERSION.tar.bz2
    cd greylite-VERSION
    
  3. compile and install:
    make all install

Notes for special compilation

Several arguments can be appended to the command line for enabling compilation of different components. The general form is:

make all install ARGUM1 ARGUM2 ARGUM3 ...

WITH_GEOIP=yes enables support for GeoIP in suspicion rules.

WITH_DNSBLENV=yes enables the compilation of the dnsblenv module.

WITH_UCSPI2SOCKET=yes enables the compilation of the ucspi2socket module.

In greylite ≥ 3.0 the backend for storing data can be chosen. By default, SQLite is used. The following can be specified for changing this:

On some systems the libraries and headers of these softwares are placed in non-standard paths. These paths can then be pointed with two further make arguments: x_INCLUDE_DIR=/path and x_LIB_DIR=/path. Replace x with the name of the backend (MYSQL, PGSQL).

Setup in the system

  1. Setup the database depending on the backend you want to use:
  2. run greylite under tcpserver:
    tcpserver -vR -x greylite.cdb BINDIP BINDPORT /usr/local/bin/greylite /usr/local/bin/ucspi2socket UPSTREAMADDR [UPSTREAMPORT]
    replace BINDIP and BINDPORT with the IP address greylite should respond to, respectively. Replace UPSTREAMADDR and optionally UPSTREAMPORT with the IP address and port of the upstream SMTP server that greylite should connect to.
  3. greylite.cdb is a CDB file to tell tcpserver what connections to accept and what environment variables to set after responding to them. This is the default ruleset for accepting connections and enabling greylisting for all addressess (see tcprules for more information, and greylite controls for more customizations):
    :allow,GREYLIST=""
    
    Compile this ruleset into a CDB file with:
    cat rulesfile | tcprules greylite.cdb /tmp/greylite.123

Done.