Aug 092011

I was rewrote Omar Kilani’s memcache patch couple of weeks ago. But that was not tested due to lack of time and unavailability of servers that can be used.

Now, i got chance to implement simple test. This is my configuration:

smtpd_recipient_restrictions =
   check_recipient_access memcache:/etc/postfix/,

servers = localhost:11211
key_format = %s

Entry on memcache	REJECT	not allowed

Query using postmap

$ postmap -q "" memcache:/etc/postfix/
postmap: dict_memcache_lookup: using key_format '%s'
postmap: plmemcache_get: fetching key from memcache
postmap: plmemcache_get: key => REJECT not allowed
postmap: dict_memcache_lookup: returned REJECT not allowed
REJECT not allowed

A little bit too verbose i guess, but it can be adjusted by modifying source code.
Continue reading »

Jul 202011

I have not had time to do the test “postfix memcached patch” because there are no idle servers that can be used for the experiment. instead, I’ve made a tutorial how to integrate memcached as a “postfix lookup table” with the help of tcp_table and a simple perl script.

Indeed, tcp_table “table lookup protocol” is one of the most powerful tools as well as the regexp and pcre, in my opinion. although client-server connection is not protected and and the server is not authenticated.

yes, I did a lot of experiments using tcp_table and perl scripts. it made me realize that I can do almost everything I need and make postfix as my favorite MTA.

Things required:

OK, first we create a simple perl script that allows you to handle the protocols of tcp_table. let’s call it

use strict;
use warnings;
use Sys::Syslog qw(:DEFAULT setlogsock);
use Cache::Memcached;

# Configure the memcached server
my $memd = new Cache::Memcached {
            'servers' => [ '' ],

# Initalize and open syslog.

sub qrymemc {
        return unless /^get\s+(.+)/i;
        my $kmemc = lc($1);
        my $vmemc = $memd->get($kmemc);
        if (defined $vmemc) {
                return ($kmemc,$vmemc);

sub trim{

# Autoflush standard output.
select STDOUT; $|++;

while (<>) {
        if (/^get\s+(.+)/i) {
                my $data = lc($1);
                my @res = qrymemc($data);
                syslog("info","data: %s", $data);
                if (@res) {
                        print "200 $res[1]\n";
                        syslog("info","Found: key = %s, value = %s", $res[0], $res[1]);
        print "200 DUNNO\n";

Continue reading »