procmail
[Top] [All Lists]

Re: (special) autoreply problem

2004-11-19 09:29:04
On Fri, Nov 19, 2004 at 02:47:57PM +0100, Thoralf Will wrote:
On Thu, Nov 18, 2004 at 11:52:04PM +0000, Alan Clifford wrote:
On Thu, 18 Nov 2004, Thoralf Will wrote:

TW> Hi all,
TW> 
TW> I'm new to procmail and didn't find any solution for this problem yet:
TW> 
TW> Every mail received in a special Mailbox should get an autoreply after
TW> a defined delay (e.g. 30 minutes) but not more than 1 reply within
TW> 24h to the same address.
TW> The received mail itself is not of importance and can (or better should)
TW> get deleted after getting parsed.
TW> 
TW> Currently I'm using a combination of cron and reply-o-matic (rom) but
TW> that's not the best solution and causing some problems because rom has
TW> a few bugs.
TW> 
TW> Any idea how to do it?
TW> 

I put my auto-replies in the sendmail queue and the queue is sent every 
half hour by sendmail.  Not quite what you want but maybe good enough?

Not exactly but it would be ok if no better solution is available.
 
To prevent multiple auto-replies to the same address, the autoresponder 
adds addresses to a list and doesn't respond to addresses in the list. I 
run a cron job to wipe out this list at an interval of choice.

How does your autoresponder work? Can you give me a sample? The problem is
that I can't wipe the whole list at the same time. That means I would have
to log a timestamp along with the address which makes it even more complex.
I was rather looking for an already existing solution in favour to writing
my own (probably even buggier) scripts to take care of this.

I would do this by saving the names to be acked (acknowledged)
individual filenames.  Thus your timestamp is right there, no extra
work.  Once the ack is sent, change fileperms as a flag.  Once 24 hours
have passed, delete the file.

If you don't have any big time-gaps during which your server doesn't get
mail, you can check the "time-to-live" in procmail as well.  Otherwise,
you might need a frequently running cron job or a daemon, depending
on how big this list is and how accurate you need to be with the
timing of the ack.

Hell, you could even just use the very same "vacation" recipe mentioned
in "man procmailex", but instead of piping it to sendmail at the end,
redirect the output -- full message, ready for sendmail -- to the file.


  :0
   * condition ascertaining member of list to ack
   { MYACKGUY = `formail -rtzf -xTo:`}

   :0 A  other flags : $MYACKGUY$LOCKEXT
   * vacation stuff from "man procmailex"
   | vacation action from "man procmailex" > /var/tmp/acks/$MYACKGUY

That's all the prep-work.  Now we need to have a recipe set to do the
acks on queue and add our permissions "flag."

First, though, we can delete the files older than 24 hours.  ("gfind"
is GNU find on my system.)

   :0 hi
   | gfind /var/tmp/acks/ -maxdepth 1 -type f -daystart -mtime +1 -exec rm -f 
{} \;\
           2>/dev/null

Similarly, we can use GNU find to check the 30-minute window.  I know
gfind can handle seconds and minutes, but I don't have the syntax on the
tip of my fingers.  Do a little research.  Assuming you have the write
timeflag syntax for find, something like this will suffice:

 MYFILES =`gfind /var/tmp/acks/ -maxdepth 1 -type f -[time over 30m] -perm 600  
2>/dev/null`

 :0 hi
 | $SENDMAIL $SENDMAILFLAGS < $MYFILES && chmod g+x $MYFILES

That's it!


This is not fully tested as to details here, but I use similar concepts in
other things and they work.

-- 
dman

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>