.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Received 3pm" .TH Received 3pm "2021-01-08" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mail::Field::Received \-\- mostly RFC822\-compliant parser of Received headers .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Mail::Field; \& \& my $received = Mail::Field\->new(\*(AqReceived\*(Aq, $header); \& my $results = $received\->parse_tree(); \& my $parsed_ok = $received\->parsed_ok(); \& my $diagnostics = $received\->diagnostics(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDon't use this class directly!\fR Instead ask Mail::Field for new instances based on the field name! .PP Mail::Field::Received provides subroutines for parsing Received headers from e\-mails. It mostly complies with \s-1RFC822,\s0 but deviates to accommodate a number of broken MTAs which are in common use. It also attempts to extract useful information which MTAs often embed within the \f(CW\*(C`(comments)\*(C'\fR. .PP It is a subclass derived from the Mail::Field and Mail::Field::Generic classes. .SH "ROUTINES" .IX Header "ROUTINES" .IP "\(bu" 4 \&\fBdebug\fR .Sp Returns current debugging level obtained via the \f(CW\*(C`diagnostics\*(C'\fR method. If a parameter is given, the debugging level is changed. The default level is 3. .IP "\(bu" 4 \&\fBdiagnose\fR .Sp .Vb 1 \& $received\->diagnose("foo", "\en"); .Ve .Sp Appends stuff to the parser's diagnostics buffer. .IP "\(bu" 4 \&\fBdiagnostics\fR .Sp .Vb 1 \& my $diagnostics = $received\->diagnostics(); .Ve .Sp Returns the contents of the parser's diagnostics buffer. .IP "\(bu" 4 \&\fBparse\fR .Sp The actual parser. Returns the object (Mail::Field barfs otherwise). .IP "\(bu" 4 \&\fBparsed_ok\fR .Sp .Vb 3 \& if ($received\->parsed_ok()) { \& ... \& } .Ve .Sp Returns true if the parse succeed, or if it failed, but was permitted to fail for some reason, such as encountering evidence of a known broken (non\-RFC822\-compliant) format mid-parse. .IP "\(bu" 4 \&\fBparse_tree\fR .Sp .Vb 1 \& my $parse_tree = $received\->parse_tree(); .Ve .Sp Returns the actual parse tree, which is where you get all the useful information. It is returned as a hashref whose keys are strings like `from', `by', `with', `id', `via' etc., corresponding to the components of Received headers as defined by \s-1RFC822:\s0 .Sp .Vb 8 \& received = "Received" ":" ; one per relay \& ["from" domain] ; sending host \& ["by" domain] ; receiving host \& ["via" atom] ; physical path \& *("with" atom) ; link/mail protocol \& ["id" msg\-id] ; receiver msg id \& ["for" addr\-spec] ; initial form \& ";" date\-time ; time received .Ve .Sp The corresponding values are more hashrefs which are mini-parse-trees for these individual components. A typical parse tree looks something like: .Sp .Vb 10 \& { \& \*(Aqby\*(Aq => { \& \*(Aqdomain\*(Aq => \*(Aqhost5.hostingcheck.com\*(Aq, \& \*(Aqwhole\*(Aq => \*(Aqby host5.hostingcheck.com\*(Aq, \& \*(Aqcomments\*(Aq => [ \& \*(Aq(8.9.3/8.9.3)\*(Aq \& ], \& }, \& \*(Aqdate_time\*(Aq => { \& \*(Aqyear\*(Aq => 2000, \& \*(Aqweek_day\*(Aq => \*(AqTue\*(Aq, \& \*(Aqminute\*(Aq => 57, \& \*(Aqday_of_year\*(Aq => \*(Aq1 Feb\*(Aq, \& \*(Aqmonth_day\*(Aq => \*(Aq 1\*(Aq, \& \*(Aqzone\*(Aq => \*(Aq\-0500\*(Aq, \& \*(Aqsecond\*(Aq => 18, \& \*(Aqhms\*(Aq => \*(Aq21:57:18\*(Aq, \& \*(Aqdate_time\*(Aq => \*(AqTue, 1 Feb 2000 21:57:18 \-0500\*(Aq, \& \*(Aqhour\*(Aq => 21, \& \*(Aqmonth\*(Aq => \*(AqFeb\*(Aq, \& \*(Aqrest\*(Aq => \*(Aq2000 21:57:18 \-0500\*(Aq, \& \*(Aqwhole\*(Aq => \*(AqTue, 1 Feb 2000 21:57:18 \-0500\*(Aq \& }, \& \*(Aqwith\*(Aq => { \& \*(Aqwith\*(Aq => \*(AqESMTP\*(Aq, \& \*(Aqwhole\*(Aq => \*(Aqwith ESMTP\*(Aq \& }, \& \*(Aqfrom\*(Aq => { \& \*(Aqdomain\*(Aq => \*(Aqmediacons.tecc.co.uk\*(Aq, \& \*(AqHELO\*(Aq => \*(Aqtr909.mediaconsult.com\*(Aq, \& \*(Aqfrom\*(Aq => \*(Aqtr909.mediaconsult.com\*(Aq, \& \*(Aqaddress\*(Aq => \*(Aq193.128.6.132\*(Aq, \& \*(Aqcomments\*(Aq => [ \& \*(Aq(mediacons.tecc.co.uk [193.128.6.132])\*(Aq, \& ], \& \*(Aqwhole\*(Aq => \*(Aqfrom tr909.mediaconsult.com (mediacons.tecc.co.uk [193.128.6.132]) \&\*(Aq \& }, \& \*(Aqid\*(Aq => { \& \*(Aqid\*(Aq => \*(AqVAA24164\*(Aq, \& \*(Aqwhole\*(Aq => \*(Aqid VAA24164\*(Aq \& }, \& \*(Aqcomments\*(Aq => [ \& \*(Aq(mediacons.tecc.co.uk [193.128.6.132])\*(Aq, \& \*(Aq(8.9.3/8.9.3)\*(Aq \& ], \& \*(Aqfor\*(Aq => { \& \*(Aqfor\*(Aq => \*(Aq\*(Aq, \& \*(Aqwhole\*(Aq => \*(Aqfor \*(Aq \& }, \& \*(Aqwhole\*(Aq => \*(Aqfrom tr909.mediaconsult.com (mediacons.tecc.co.uk [193.128.6.132]) by host5.hostingcheck.com (8.9.3/8.9.3) with ESMTP id VAA24164 for ; Tue, 1 Feb 2000 21:57:18 \-0500\*(Aq \& } .Ve .SH "BUGS" .IX Header "BUGS" Doesn't use Parse::RecDescent, which it maybe should. .PP Doesn't offer a `strict \s-1RFC822\s0' parsing mode. To implement that would be a royal pain in the arse, unless we move to Parse::RecDescent. .SH "SEE ALSO" .IX Header "SEE ALSO" Mail::Field, Mail::Header .SH "AUTHOR" .IX Header "AUTHOR" Adam Spiers .SH "LICENSE" .IX Header "LICENSE" All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.