summaryrefslogtreecommitdiff
path: root/regress/message/bounce.pl
blob: a3767d1c52cefc1f0112ffb6947aec32afcbffec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env perl
#-*- 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: bounce.pl,v 1.9 2005/07/27 12:16:20 fukachan Exp $
#

use strict;
use Carp;
use lib qw(../../cpan/lib);
use Mail::Message;

use FML::Test::Utils;
my $tool = new FML::Test::Utils;

for my $f (@ARGV) {
    print "// check $f\n" if $ENV{'debug'};
    my $fh  = new FileHandle $f;
    my $msg = Mail::Message->parse( { fd => $fh } );
    my $r   = {};

    use Mail::Bounce;
    my $bouncer = new Mail::Bounce;
    $bouncer->analyze( $msg );
    print "\n--- result (debug)\n\n" if $ENV{'debug'};
    printf "# %-40s ... %s\n", $f, ($bouncer->address_list ? "ok" : "fail");

    if ($ENV{'dump'}) { 
	eval qq{ require Data::Dumper; Data::Dumper->import();};
	print $@ if $@;
	eval q{ print Dumper( $msg ); };
    }

    for my $a ( $bouncer->address_list ) {
	print "address: $a\n";

	print " status: ";
	print $bouncer->status( $a );
	print "\n";

	print " reason: ";
	print $bouncer->reason( $a );
	print "\n";

	print "  hints: ";
	print $bouncer->hints( $a );
	print "\n";

	print "\n";
    }
}

exit 0;