summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-04-09 15:56:52 +0000
committerfukachan <fukachan>2001-04-09 15:56:52 +0000
commite62750548de8d3a6a322e64bd32486824daae06d (patch)
tree8bd40cb479b4f8956fb57d65f6c7a4aaf75d7b86
parent04bc134819d8cb629ab806de044292d15e11fe7c (diff)
downloadfml8-e62750548de8d3a6a322e64bd32486824daae06d.tar.gz
fml8-e62750548de8d3a6a322e64bd32486824daae06d.tar.bz2
fml8-e62750548de8d3a6a322e64bd32486824daae06d.zip
enable to parse qmail error message (though not include VERPs)
-rw-r--r--fml/lib/Mail/Bounce/00_PARSE.ja.txt52
-rw-r--r--fml/lib/Mail/Bounce/00_README.ja.txt3
-rw-r--r--fml/lib/Mail/Bounce/Qmail.pm95
-rwxr-xr-xregress/message/bounce.pl4
-rw-r--r--regress/testmails/error=qmail130
5 files changed, 231 insertions, 53 deletions
diff --git a/fml/lib/Mail/Bounce/00_PARSE.ja.txt b/fml/lib/Mail/Bounce/00_PARSE.ja.txt
index 63067edf..b963b84a 100644
--- a/fml/lib/Mail/Bounce/00_PARSE.ja.txt
+++ b/fml/lib/Mail/Bounce/00_PARSE.ja.txt
@@ -63,13 +63,6 @@ sub Parse
}
}
- if ($original_mail && $found && $debug) {
- &Debug(" --- $_") if $debug;
- }
- elsif ($debug) {
- &Debug(" | $_") if $debug;
- }
-
$new_block = 1 if /^\s*$/;
if (/^From:.*mailer-daemon/i || /^From:.*postmaster/) {
@@ -84,10 +77,7 @@ sub Parse
$MTA = "exim";
next;
}
- if (/qmail-send/) {
- $MTA = "qmail";
- next;
- }
+
# get returned addresses
if ($first_header_part) {
@@ -119,25 +109,6 @@ sub Parse
&PickUpHint($1);
}
- #####
- ##### MTA szpecific
- #####
- # postfix
- # <uja@beth.fml.org>: unknown user
- if ($mp_block eq 'Content-Description: Notification') {
- if (/^\s*(\S+\@\S+):\s*(unknown user|.*:\s+5\d\d\s+.*)/) {
- $CurAddr = $1;
- $CurAddr =~ s/[\<\>]//g;
- $CurAddr =~ s/\s*//g;
- &Debug("CurAddr => $CurAddr") if $debug && $CurAddr;
- $MTA = 'postfix';
- }
- }
-
- # exim || qmail
- if ($MTA eq 'qmail' && /This is a permanent error/) {
- $RABuf .= $_;
- }
if ($MTA eq 'exim' || $MTA eq 'qmail') {
/^\s*(\S+\@\S+):\s*$/ && ($CurAddr = $1);
@@ -162,14 +133,6 @@ sub Parse
&Debug("P_CurAddr => $P_CurAddr") if $debug && $P_CurAddr;
}
- # error message line
- # next if /<<<.*\@/;
- # next if /^Diagnostic-Code:/i;
-
- # ignore the original mails
- # &Debug("next") if $original_mail && $found;
- next if $original_mail && $found;
- $original_mail = 1 if /^received:/i;
##### TRAP CODE #####
if (/fatal error/i) { $fatal++;}
@@ -217,19 +180,6 @@ sub Parse
}
###
- ### qmail
- ###
- if (/\#5\.\d+\.\d+/ && $MTA eq 'qmail') {
- &AnalyzeErrorWord($_, $CurAddr);
- $found++;
- }
-
- if ($MTA eq 'qmail' && $CurAddr && $RABuf) {
- &AnalyzeErrorWord($RABuf, $CurAddr);
- $found++;
- }
-
- ###
### sendmail
###
if ($fatal) {
diff --git a/fml/lib/Mail/Bounce/00_README.ja.txt b/fml/lib/Mail/Bounce/00_README.ja.txt
index d7ce6f17..a9dbfb15 100644
--- a/fml/lib/Mail/Bounce/00_README.ja.txt
+++ b/fml/lib/Mail/Bounce/00_README.ja.txt
@@ -5,6 +5,9 @@
入力の最大値は?
+ エラーを起こした元のメールをどうとらえるか?
+ 例えば、そのエラーになった Received: の系列をどう扱うか
+
出力は
ハッシュで {
diff --git a/fml/lib/Mail/Bounce/Qmail.pm b/fml/lib/Mail/Bounce/Qmail.pm
new file mode 100644
index 00000000..9271b7a4
--- /dev/null
+++ b/fml/lib/Mail/Bounce/Qmail.pm
@@ -0,0 +1,95 @@
+#-*- perl -*-
+#
+# Copyright (C) 2001 Ken'ichi Fukamachi
+# All rights reserved. This program is free software; you can
+# redistribute it and/or modify it under the same terms as Perl itself.
+#
+# $FML: Qmail.pm,v 1.3 2001/04/09 15:31:48 fukachan Exp $
+#
+
+
+package Mail::Bounce::Qmail;
+
+use strict;
+use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
+use Carp;
+
+=head1 NAME
+
+Mail::Bounce::Qmail - Qmail error message format parser
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+Parse bounce messages generated by qmail.
+
+Qmail actually has a standard, called QSBMF (qmail-send bounce message
+format), as describbed in
+
+ http://cr.yp.to/proto/qsbmf.txt
+
+=head1 METHODS
+
+=head2 C<new()>
+
+=cut
+
+sub analyze
+{
+ my ($self, $msg) = @_;
+ my $result = {};
+ my $state = 0;
+ my $pattern = 'Hi. This is the';
+ my $end_pattern = '--- Undelivered message follows ---';
+
+ # search data
+ my ($addr, $reason);
+ my $m = $msg->{ next };
+ do {
+ if (defined $m) {
+ my $num = $m->num_paragraph;
+ for ( my $i = 0; $i < $num ; $i++ ) {
+ my $data = $m->nth_paragraph( $i + 1 );
+
+ if ($data =~ /$pattern/) { $state = 1;}
+ if ($data =~ /$end_pattern/) { $state = 0;}
+
+ if ($state == 1) {
+ $data =~ s/\n/ /g;
+ if ($data =~ /\<(\S+\@\S+)\>:\s*(.*)/) {
+ ($addr, $reason) = ($1, $2);
+ $result->{ $addr }->{ 'Diagnostic-Code' } = $reason;
+ $result->{ $addr }->{ 'Status' } = '5.x.y';
+ }
+ }
+ }
+ }
+
+ $m = $m->{ next };
+ } while (defined $m);
+
+ $result;
+}
+
+
+=head1 AUTHOR
+
+Ken'ichi Fukamachi
+
+=head1 COPYRIGHT
+
+Copyright (C) 2001 Ken'ichi Fukamachi
+
+All rights reserved. This program is free software; you can
+redistribute it and/or modify it under the same terms as Perl itself.
+
+=head1 HISTORY
+
+Mail::Bounce::Qmail appeared in fml5 mailing list driver package.
+See C<http://www.fml.org/> for more details.
+
+=cut
+
+
+1;
diff --git a/regress/message/bounce.pl b/regress/message/bounce.pl
index 7bd2591b..7b60a2ae 100755
--- a/regress/message/bounce.pl
+++ b/regress/message/bounce.pl
@@ -5,7 +5,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: bounce_dsn.pl,v 1.1 2001/04/08 16:17:30 fukachan Exp $
+# $FML: bounce.pl,v 1.1 2001/04/09 15:33:30 fukachan Exp $
#
use strict;
@@ -18,7 +18,7 @@ for my $f (@ARGV) {
my $msg = Mail::Message->parse( { fd => $fh } );
my $r = {};
- for my $pkg ('DSN', 'Postfix19991231') {
+ for my $pkg ('DSN', 'Postfix19991231', 'Qmail') {
print "--- $pkg\n";
eval qq {
require Mail::Bounce::$pkg;
diff --git a/regress/testmails/error=qmail b/regress/testmails/error=qmail
new file mode 100644
index 00000000..d78caf0e
--- /dev/null
+++ b/regress/testmails/error=qmail
@@ -0,0 +1,130 @@
+Received: by hikari.fml.org (8.9.3/3.4W6+Hikari-2.1) with ESMTP id KAA16046 for <fukachan@fml.org>; Mon, 9 Apr 2001 10:47:14 +0900 (UTC)
+Received: by eve.fml.org; id KAA05288; Mon, 9 Apr 2001 10:47:13 +0900 (JST)
+Message-Id: <200104090147.KAA05288@eve.fml.org>
+Received: from ahodori.fml.org(202.232.137.17) by eve.fml.org via smap (V4.2)
+ id xma005274; Mon, 9 Apr 01 10:46:56 +0900
+Received: (qmail 8592 invoked by alias); 9 Apr 2001 01:46:55 -0000
+Delivered-To: fml-help-admin@ffs.fml.org
+Received: (qmail 8589 invoked for bounce); 9 Apr 2001 01:46:55 -0000
+Date: 9 Apr 2001 01:46:54 -0000
+From: MAILER-DAEMON@ahodori.fml.org
+To: fml-help-admin@ffs.fml.org
+Subject: failure notice
+X-UIDL: 80b94f1ce6547bd9cabdf6367d5325ca
+
+Hi. This is the qmail-send program at ahodori.fml.org.
+I'm afraid I wasn't able to deliver your message to the following addresses.
+This is a permanent error; I've given up. Sorry it didn't work out.
+
+<yukihiro@jscsoho.co.nuinui.net>:
+Sorry, I couldn't find a mail exchanger or IP address. (#5.4.4)
+
+<cipherxx@sunfield.or.nuinui.net>:
+Sorry, I couldn't find any host named sunfield.or.nuinui.net. (#5.1.2)
+
+<Yamashitaxx@plexus.co.nuinui.net>:
+210.164.86.18 does not like recipient.
+Remote host said: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
+Giving up on 210.164.86.18.
+
+<utada_kxx@usa.net>:
+204.68.24.19 does not like recipient.
+Remote host said: 550 <utada_kxx@usa.net>... User account is no longer active
+Giving up on 204.68.24.19.
+
+<kkawasakixx@ibm.net>:
+Sorry, I couldn't find any host named ibm.net. (#5.1.2)
+
+<ondaxx@ltsc.co.nuinui.net>:
+Connected to 210.188.236.3 but sender was rejected.
+Remote host said: 550 Can not speak with you
+
+<ml-adminxx@arch.nuinui.net>:
+150.69.133.2 does not like recipient.
+Remote host said: 550 5.1.1 <ml-adminxx@arch.nuinui.net>... User unknown
+Giving up on 150.69.133.2.
+
+<kzkxx@izumi.is.seisen-u.ac.nuinui.net>:
+210.137.255.41 does not like recipient.
+Remote host said: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
+Giving up on 210.137.255.41.
+
+<hnakataxx@gunmanuinui.net>:
+133.8.40.242 does not like recipient.
+Remote host said: 553 <hnakataxx@gunmanuinui.net>... Relay operation rejected
+Giving up on 133.8.40.242.
+
+<hayasakaxx@fh.nuinui.net>:
+150.7.239.66 does not like recipient.
+Remote host said: 550 <hayasakaxx@fh.nuinui.net>, Recipient unknown
+Giving up on 150.7.239.66.
+
+<noruxx@psyence-web.net>:
+Sorry, I couldn't find any host by that name. (#4.1.2)
+I'm not going to try again; this message has been in the queue too long.
+
+<qrpxx@Legacy.subarist.com>:
+CNAME lookup failed temporarily. (#4.4.3)
+I'm not going to try again; this message has been in the queue too long.
+
+--- Below this line is a copy of the message.
+
+Return-Path: <fml-help-admin@ffs.fml.org>
+Received: (qmail 7869 invoked from network); 1 Apr 2001 23:52:46 -0000
+Received: from localhost (HELO albatros.fml.org) (127.0.0.1)
+ by localhost with SMTP; 1 Apr 2001 23:52:46 -0000
+Return-Path: <fml-help-admin@ffs.fml.org>
+Received: from eve.fml.org (eve.fml.org [202.232.14.18])
+ by ahodori.fml.org (Postfix) with ESMTP
+ id 8767D86661; Mon, 2 Apr 2001 08:52:31 +0900 (JST)
+Received: by eve.fml.org; id IAA00756; Mon, 2 Apr 2001 08:52:31 +0900 (JST)
+Received: from katri.fml.org(192.168.148.14) by eve.fml.org via smap (V4.2)
+ id xma000741; Mon, 2 Apr 01 08:51:39 +0900
+Received: by katri.fml.org (Postfix, from userid 1106)
+ id C44165B39A; Mon, 2 Apr 2001 08:51:35 +0900 (JST)
+Delivered-To: fml-help@ffs.fml.org
+Date: Mon, 2 Apr 2001 08:52:35 +0900
+X-Posted: Mon, 2 Apr 2001 08:51:35 +0900 (JST)
+From: fukachan@cvs.fml.org
+Reply-To: fml-help@ffs.fml.org
+Subject: fml cvs weekly changes (20010402)
+Sender: fukachan@katri.fml.org
+To: fml-users@ffs.fml.org, fml-help@ffs.fml.org
+Message-Id: <20010401235135.C44165B39A@katri.fml.org>
+X-ML-Name: fml-help
+X-Mail-Count: 00085
+X-MLServer: fml [fml 4.0A (20010323)]; post only (only members can post)
+X-ML-Info: If you have a question, send e-mail with the body
+ "help" (without quotes) to the address fml-help-ctl@ffs.fml.org;
+ help=<mailto:fml-help-ctl@ffs.fml.org?body=help>
+Precedence: bulk
+Lines: 23
+List-Software: fml [fml 4.0A (20010323)]
+List-Post: <mailto:fml-help@ffs.fml.org>
+List-Owner: <mailto:fml-help-admin@ffs.fml.org>
+List-Help: <mailto:fml-help-ctl@ffs.fml.org?body=help>
+List-Unsubscribe: <mailto:fml-help-ctl@ffs.fml.org?body=unsubscribe>
+
+
+Updating fml tree:
+U CHANGES
+U Makefile
+U Makefile.local
+U doc/Japanese/internals/overview.wix
+U doc/devel/OS_and_Perl.txt
+U doc/ri/CHANGES-4.0.1.wix
+U doc/ri/INSTALL_with_POSTFIX.wix
+U doc/ri/TODO.wix
+U kern/Makefile
+U messages/Japanese/amctl
+U proc/libamctl.pl
+
+Updating stable fml tree (fml-4-0-maint):
+U doc/Japanese/internals/overview.wix
+U doc/ri/CHANGES-4.0.1.wix
+U doc/ri/INSTALL_with_POSTFIX.wix
+U kern/Makefile
+U messages/Japanese/amctl
+U proc/libamctl.pl
+
+-- fukachan@cvs.fml.org