1Email::Received(3)    User Contributed Perl Documentation   Email::Received(3)
2
3
4

NAME

6       Email::Received - Parse an email Received: header
7

SYNOPSIS

9         use Email::Received;
10
11         for ($mail->header("Received")) {
12           my $data = parse_received($_);
13           return "SPAM" if rbl_lookup($data->{ip});
14         }
15

DESCRIPTION

17       This module is a Perl Email Project rewrite of SpamAssassin's email
18       header parser. We did this so that the great work they did in analysing
19       pretty much every possible Received header format could be used in
20       applications other than SpamAssassin itself.
21
22       The module provides one function, "parse_received", which takes a
23       single Received line. It then produces either nothing, if the line is
24       unparsable, a hash reference like this:
25
26           { reason => "gateway noise" }
27
28       if the line should be ignored for some good reason, and one like this:
29
30          { ip => '64.12.136.4', id => '875522', by => 'xxx.com',
31            helo => 'imo-m01.mx.aol.com' }
32
33       if it parsed the message. Possible keys are:
34
35           ip rdns helo ident envfrom auth by id
36

RULE FORMAT

38       Where SpamAssassin used a big static subroutine full of regular
39       expressions to parse the data, we build up a big subroutine full of
40       regular expressions dynamically from a set of rules. The rules are
41       stored at the bottom of this module. The basic format for a rule looks
42       like this:
43
44           ((var=~)?/REGEXP/)? [ACTION; ]+
45
46       The "ACTION" is either "SET variable = $value", "IGNORE "reason"?",
47       "UNPARSABLE" or "DONE".
48
49       One control structure is provided, which is basically an "if"
50       statement:
51
52           GIVEN (NOT)? /REGEXP/ {
53               ACTION+
54           }
55
56   EXPORT
57       parse_received
58

SEE ALSO

60       Mail::SpamAssassin::Message::Metadata::Received, from which the rules
61       and some of the IP address matching constants were blatantly stolen.
62       Thanks, guys, for doing such a comprehensive job!
63

AUTHOR

65       simon, <simon@>
66
68       Copyright (C) 2006 by simon
69
70       This library is free software; you can redistribute it and/or modify it
71       under the same terms as Perl itself, either Perl version 5.8.7 or, at
72       your option, any later version of Perl 5 you may have available.
73
74
75
76perl v5.36.0                      2022-07-22                Email::Received(3)
Impressum