OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Avoid recursive table lookup

From: Arnaud JAYET (ajayetfree.fr)
Date: Tue Jun 09 2009 - 02:02:36 CDT


Hello,

i'm trying to set up a Vacation Mail Responder using postfix and special
transport + PERL script.

i want to let users choose between :
case 1 : automatic vacation responding and not delivrering the original
message (message is lost)
case 2 : automatic vacation responding and delivrering original message
in their mailbox

note : i'm using a MySQL lookup for storing users vacation parameters
but i have got the same problem with standard db lookup

My configuration

transport :
autoreply.domain.tld: autoreply

master.cf :

autoreply unix - n n - - pipe
   flags=Oqu user=nobody argv=/usr/local/bin/vacation.pl $sender $recipient

main.cf :

virtual_alias_maps =
         hash:/etc/postfix/vir_vacation,
         ...
         ...
     ...

in vir_vacation i can have

case 1 :
userdomain.tld userautoreply.domain.tld

case 2:
userdomain.tld userautoreply.domain.tld,userdomain.tld

in case 1, all is fine, original sender receives the automatic mail

but in case 2, PERL script is called twice (but the message is well
delivered in user's mailbox) and so there is 2 automatic mail sent to
original sender

how can avoid this "recursive" lookup in the table and sending automatic
vacation message twice ?

Note : I found a solution for case 2 using another transport to deliver
  the original mail and sending a vacation mail :

transport :
autoreply.domain.tld: autoreply
deliverdomain.tld: relay:[imapserver.domain.tld]

case 2:
userdomain.tld userautoreply.domain.tld,userdeliver.domain.tld

on the imap server i have a canonical regexp to rewrite
userdeliver.domain.tld --> userdomain.tld

/^(.*)deliver.domain.tld/ ${1}domain.tld

but if i could avoid this ("heavy" ?) solution....