From f5fab65b2dd5fc8a008ea46c78dc8b833042ffa4 Mon Sep 17 00:00:00 2001 From: fukachan Date: Tue, 10 Apr 2001 11:48:53 +0000 Subject: top level entrance interface for Mail::Bounce::* analyzers --- fml/lib/Mail/Bounce.pm | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 fml/lib/Mail/Bounce.pm (limited to 'fml/lib') diff --git a/fml/lib/Mail/Bounce.pm b/fml/lib/Mail/Bounce.pm new file mode 100644 index 00000000..7a85e620 --- /dev/null +++ b/fml/lib/Mail/Bounce.pm @@ -0,0 +1,105 @@ +#-*- 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: __template.pm,v 1.5 2001/04/03 09:45:39 fukachan Exp $ +# + +package Mail::Bounce; +use strict; +use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); +use Carp; + +=head1 NAME + +Mail::Bounce - analye error messages + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=head2 C + +=cut + + +sub new +{ + my ($self) = @_; + my ($type) = ref($self) || $self; + my $me = {}; + return bless $me, $type; +} + + +sub analyze +{ + my ($self, $msg) = @_; + my $result = {}; + + for my $pkg ('DSN', 'Postfix19991231', 'Qmail') { + eval qq { + require Mail::Bounce::$pkg; + Mail::Bounce::$pkg->import(); + Mail::Bounce::$pkg->analyze( \$msg , \$result); + }; + croak($@) if $@; + } + + $self->{ _result } = $result; +} + + +sub address_list +{ + my ($self) = @_; + my $result = $self->{ _result }; + return keys %$result; +} + + +sub status +{ + my ($self, $addr) = @_; + my $status = $self->{ _result }->{ $addr }->{ 'Status' }; + $status =~ s/\s+/ /g; + $status =~ s/\s*$//; + $status; +} + + +sub reason +{ + my ($self, $addr) = @_; + my $reason = $self->{ _result }->{ $addr }->{ 'Diagnostic-Code' }; + $reason =~ s/\s+/ /g; + $reason =~ s/\s*$//; + $reason; +} + + + +=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 appeared in fml5 mailing list driver package. +See C for more details. + +=cut + + +1; -- cgit v1.2.1