On Fri, Aug 17, 2001 at 08:50:28AM +0200, Wolfgang Pichler wrote:
> Hi
> Is it possible to send a "warn message" to the sender if a message which
> has the sender put into the queue couldn't be delivered immediatley ?
>
> Pichler Wolfgang
>
Yes, I use qmail-lagcheck. Beware that the one on the qmail.org site
has some bugs, though. Here's my version, which fixes some things and changes
the message to be a little more clear.. Too many users starting up a
conversation with mailer-daemon :)
*** qmail-lagcheck Fri Aug 17 16:46:44 2001
--- qmail-lagcheck-0.9.1 Fri Aug 17 16:49:50 2001
***************
*** 6,18 ****
# Matt Ranney ([EMAIL PROTECTED])
#
! # Version 0.8
! $QMAIL_HOME='/home/qmail';
$QUEUEDIR="$QMAIL_HOME/queue";
$FIRST_NOTICE=4; # time in hours
$REGULAR_NOTICE=24;# also time in hours
! $ADMIN_CC="postmaster\@vfi.com";
open(ME, "$QMAIL_HOME/control/me") || die "Couldn't open $QMAIL_HOME/control/me for
read: $!\n";
chop($me = <ME>);
--- 6,29 ----
# Matt Ranney ([EMAIL PROTECTED])
#
! # Version 0.9.1
! # This script is intended to be run every $FIRST_NOTICE hours.
!
! # Modified by Marcus Reid <[EMAIL PROTECTED]>
! # 09-07-00 Don't notify if time remaining in queue is negative.
! # Make it more apparent that it's an automatically generated
! # message so customers stop thanking mailer-daemon.
! # 10-17-00 Don't notify if the 'from' field is empty.
! # 01-11-01 Bugfix. Clear subject at beginning of message creation
! # loop so as not to use the subject of the previous email
! # if the subject of the current email is blank.
!
! $QMAIL_HOME='/var/qmail';
$QUEUEDIR="$QMAIL_HOME/queue";
$FIRST_NOTICE=4; # time in hours
$REGULAR_NOTICE=24;# also time in hours
! $ADMIN_CC="postmaster\@domain.tld";
open(ME, "$QMAIL_HOME/control/me") || die "Couldn't open $QMAIL_HOME/control/me for
read: $!\n";
chop($me = <ME>);
***************
*** 62,71 ****
print "Here's a message: info/$dir/$message from $from, to $to\n";
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,
$ctime,$blksize,$blocks) = stat("info/$dir/$message");
- $notify = 0;
$delay = sprintf "%d", ((time - $ctime) / 60 / 60); # get $delay in hours
print " delay is: $delay.\n";
! if ( ($delay >= $FIRST_NOTICE) && ($delay < ($FIRST_NOTICE * 2)) ) {
$notify = 1;
print " First notice.\n"
}
--- 73,89 ----
print "Here's a message: info/$dir/$message from $from, to $to\n";
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,
$ctime,$blksize,$blocks) = stat("info/$dir/$message");
$delay = sprintf "%d", ((time - $ctime) / 60 / 60); # get $delay in hours
print " delay is: $delay.\n";
!
! $notify = 0;
! if( $from eq "" ) {
! print " From is blank, no notice.\n";
! }
! elsif ( ($qlife - $delay) < 0 ) {
! print " In queue too long already, no notice.\n";
! }
! elsif ( ($delay >= $FIRST_NOTICE) && ($delay < ($FIRST_NOTICE * 2)) ) {
$notify = 1;
print " First notice.\n"
}
***************
*** 78,86 ****
else {
print " Not due for Regular notice.\n";
}
-
}
if ($notify) {
print "message needs notification\n";
open(MESS, "mess/$dir/$message") || die "Couldn't open mess/$dir/$message
for read: $!\n";
while(<MESS>) {
--- 96,105 ----
else {
print " Not due for Regular notice.\n";
}
}
+
if ($notify) {
+ undef $subject;
print "message needs notification\n";
open(MESS, "mess/$dir/$message") || die "Couldn't open mess/$dir/$message
for read: $!\n";
while(<MESS>) {
***************
*** 97,105 ****
print INJ "Cc: $ADMIN_CC\n";
}
print INJ "From: qmail queue notification <MAILER-DAEMON\@$me>\n";
! print INJ "Subject: mail slowness\n";
print INJ "\n";
! print INJ "Hi. This is the qmail-lagcheck program on $me.\n\n";
print INJ "The message you sent around $delay hours ago with ";
print INJ "a subject of:\n";
if ($subject) {
--- 116,124 ----
print INJ "Cc: $ADMIN_CC\n";
}
print INJ "From: qmail queue notification <MAILER-DAEMON\@$me>\n";
! print INJ "Subject: Mail delivery delay notification.\n";
print INJ "\n";
! print INJ "Hello. This is an automatically generated message from
$me.\n\n";
print INJ "The message you sent around $delay hours ago with ";
print INJ "a subject of:\n";
if ($subject) {
***************
*** 123,137 ****
print INJ "unknown status)\n";
}
}
! print INJ "\nis not yet fully delivered.\n\n";
print INJ "I will keep trying to deliver this message for ";
print INJ ($qlife - $delay) . " more hours, and I will\n";
! print INJ "keep you somewhat regularly apprised of the ";
! print INJ "situation as long as it is\nin the queue.\n\n";
close (INJ);
}
else {
! print "don't notify yet.\n";
}
}
}
--- 142,156 ----
print INJ "unknown status)\n";
}
}
! print INJ "\nis not yet delivered to all recipients.\n\n";
print INJ "I will keep trying to deliver this message for ";
print INJ ($qlife - $delay) . " more hours, and I will\n";
! print INJ "email you an update every $REGULAR_NOTICE hours for ";
! print INJ "as long as it is in the queue.\n\n";
close (INJ);
}
else {
! print "don't notify.\n";
}
}
}