On Sat, Sep 13, 2003 at 11:14:30PM -0700, Matthew Parke Bostrom wrote:
> > I can easily write a custom script, and I understand cancelmsg. But
> > I'm not sure where this custom script would live.  How can such a
> > script determine that the sending of a given message has been
> > retried a number of times?  Would it have to read the logs to get
> > this information, or is there another way?
> 
> Hi,
> 
>       I don't know exactly what you are trying to do, or how much
> percision you need.
> 
>       You might be able to write a cron job that would look at the
> control files.  I think every time courier attempts to deliver a
> message, the attempt is written in the message's control file.
> 
> http://www.courier-mta.org/queue.html
> 
>       -Matthew.

Thank you.  And yes, I was thinking of doing this with cron, but I
was hoping that there would be a way to cause my script to get
invoked every time "courieresmtp" runs.  I'm using "perlfilter", but
the control files are not yet complete at the time it runs.  And
besides, this filter gets invoked from within "submit" and not
apparently during retry attempts; this is handled ultimately by
"courieresmtp", which doesn't seem to have a way to use pluggable
filters like "submit" has with "perlfilter".

But after reading your message, I got an idea: the syslog that I'm
running allows for messages to be piped through pluggable scripts,
and I'm already piping "mail.info" through such a script for other
purposes.  In that script, all I have to do is look for lines like
this (split after the initial comma for ease of reading):

 Sep 14 10:16:50 myhost courieresmtp: id=00A2AB37.3F7D9481.00016801,
  from=<[EMAIL PROTECTED]>,addr=<[EMAIL PROTECTED]>,status: deferred

If "deferred" appears at the end, I can do the moral equivalent of a
recursive grep through the $localstatedir/msgq tree for the
message's unique id (in this case, "00A2AB37.3F7D9481.00016801").
This will allow me to locate the control file, a hypothetical
version of which I have listed at the end of this message.  In the
control file, I can count the number of "I0 R Connection refused"
lines or look at the timestamp on the "D", "C", or "A" lines
following them.

If this message has been retried more than a certain number of times
or perhaps for longer than a given time period, I can then look into
the message file itself, which will be a file located under the
appropriate $localstatedir/msgs subdirectory, and whose name is
gotten by replacing the leading "C" of the control file name with
"D".  I can search for a special header in this message file to see
if it's a TMDA challenge message.  If so, I would then call
"cancelmsg" and also locally blacklist the domain (in this case,
"[EMAIL PROTECTED]").

Or something like that.  :)

Anyway, this is pretty complicated to do within syslog processing,
so I should probably fork off a new process to do everything
beginning with the grep-like thing every time I detect a deferred
message.

So barring any ability to install a filter inside of "courieresmtp",
this is how I think I'm going to tackle the problem.  Does anyone
have any other ideas?

Thanks.

This is the hypothetical control file that I referred to above:

 [EMAIL PROTECTED]
 fdns; localhost (localhost [127.0.0.1])
 e
 t
 M00A2AB37.3F7D9481.00016801
 [EMAIL PROTECTED]
 R
 N
 E1064153544
 p1063577544
 W1063563144
 A1063548745
 I0 R Connection refused
 D0 1063548745
 C1063548745
 A1063549045
 I0 R Connection refused
 D0 1063548911
 C1063548911
 A1063549211
 I0 R Connection refused
 D0 1063549010
 C1063549010
 A1063550810


-- 
 Courier User
 [EMAIL PROTECTED]


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to