Section: User Contributed Perl Documentation (3pm)
use Mail::Header; my $head = Mail::Header->new; my $head = Mail::Header->new( \*STDIN ); my $head = Mail::Header->new( [<>], Modify => 0);
Read, write, create, and manipulate MIME headers, the leading part of each modern e-mail message, but also used in other protocols like HTTP. The fields are kept in Mail::Field objects.
Be aware that the header fields each have a name part, which shall be treated case-insensitive, and a content part, which may be folded over multiple lines.
Mail::Header does not always follow the RFCs strict enough, does not help you with character encodings. It does not use weak references where it could (because those did not exist when the module was written) which costs some performance and make the implementation a little more complicated. The Mail::Message::Head implementation is much newer and therefore better.
OPTIONS is a list of options given in the form of key-value pairs, just like a hash table. Valid options are
-Option --Default FoldLength 79 MailFrom 'KEEP' Modify false
Be warned that the next constructors all require an already created header object, of which the original content will be destroyed.
"Mail::Header"object of all lines.:
"extract"will modify this array. Returns the object that the method was called on.:
"header"does multiple operations. First it will extract a header from the ARRAY, if given. It will then reformat the header (if reformatting is permitted), and finally return a reference to an array which contains the header in a printable form.:
"LENGTH"is given it sets the default fold length for the current object.
"fold_length"may be called as a static method, setting default fold lengths for tags that will be used by all
"Mail::Header"objects. See the
"fold"method for a description on how
"Mail::Header"uses these values.
`From 'line is encountered. Valid values are
"IGNORE"- ignore and discard the header,
"ERROR"- invoke an error (call die),
"COERCE"- rename them as Mail-From and
"KEEP"- keep them.:
"VALUE"is false then
"Mail::Header"will not do any automatic reformatting of the headers, other than to ensure that the line starts with the tags given.:
"undef"the tag will be extracted from the beginning of the given line. If INDEX is given, the new line will be inserted into the header at the given point, otherwise the new line will be appended to the end of the header.:
"Mail::Header"uses the following rules to determine what length to fold a line.:
"get"was called. In an array context a list of all the text from all the instances of the TAG will be returned. In a scalar context the text for the first instance will be returned.
"STDOUT"if no file descriptor is given.:
"undef"the tag will be extracted from the beginning of the given line. If INDEX is given the new line will replace the Nth instance of that tag, otherwise the first instance of the tag is replaced. If the tag does not appear in the header then a new line will be appended to the header.:
"TAG"is not given then all lines are unfolded.
The unfolding process is wrong but (for compatibility reasons) will not be repaired: only one blank at the start of the line should be removed, not all of them.
This module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/.
The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development.
Mail::Cap by Gisle Aas <[email protected]>. Mail::Field::AddrList by Peter Orbaek <[email protected]>. Mail::Mailer and Mail::Send by Tim Bunce <[email protected]>. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html
Tutoriais de Tecnologia Web