Postfix Redis

Postfix Redis Lookup Table Support

View the Project on GitHub titusjose/postfix_redis

This is a patch for postfix 2.9.x MTA to support redis lookup table. This patch depends on @antirez hiredis client library.

Apply Patch

Download the postfix source at http://www.postfix.org/download.html
Extract the file and switch to the source directory.

$ cp dict_redis.c src/global
$ cp dict_redis.h src/global
$ cp hiredis.h src/global
$ patch -p5 < Makefile.in.patch
$ patch -p5 < mail_dict.c.patch

Generating Makefiles

To generate make files run make as follows

$ make makefiles CCARGS="-DHAS_REDIS -I/usr/local/include/hiredis" AUXLIBS="-L/usr/local/lib -lhiredis"

Compile And Install Postfix

$ make
$ make install

Installing Hiredis Client Library

You can clone the code at https://github.com/antirez/hiredis/

$ make
$ make install

Optionally you can also add the folder(/usr/local/lib - default hiredis install folder) to ld.so.conf if required, so that libhiredis.so is resolvable.

Testing Lookup

To test the lookup table you can postmap the string as follows

$ postmap -q "string" redis:/etc/postfix/lookup.cf

Contents of lookup.cfg:
host = localhost
port = 6379

Configuration

The configuration file support two attributes, host and port. The default host is 127.0.0.1 and port is 6379.

Example:
host = redisdb.example.com
port = 6379

Authors and Contributors

This project includes works from @antirez.

Contact

You can contact me at titus dot nitt at gmail dot com.