table of contents
Mail::Header(3) | User Contributed Perl Documentation | Mail::Header(3) |
NAME¶
Mail::Header - manipulate MIME headers
INHERITANCE¶
SYNOPSIS¶
use Mail::Header; my $head = Mail::Header->new; my $head = Mail::Header->new( \*STDIN ); my $head = Mail::Header->new( [<>], Modify => 0);
DESCRIPTION¶
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.
METHODS¶
Constructors¶
$obj->dup
$obj->new([ARG], [OPTIONS])
Mail::Header->new([ARG], [OPTIONS])
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 true
. FoldLength => INTEGER
. MailFrom => 'IGNORE'|'COERCE'|'KEEP'|'ERROR'
. Modify => BOOLEAN
"Fake" constructors¶
Be warned that the next constructors all require an already created header object, of which the original content will be destroyed.
$obj->empty
$obj->extract(ARRAY)
$obj->header([ARRAY])
$obj->header_hashref([HASH])
example:
$fields->{From} = 'Tobias Brox <tobix@cpan.org>'; $fields->{To} = ['you@somewhere', 'me@localhost']; $head->header_hashref($fields);
$obj->read(FILEHANDLE)
Accessors¶
$obj->fold_length([TAG], [LENGTH])
In the two argument form "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.
$obj->mail_from('IGNORE'|'COERCE'|'KEEP'|'ERROR')
$obj->modify([VALUE])
Processing¶
$obj->add(TAG, LINE [, INDEX])
$obj->as_string
$obj->cleanup
$obj->combine(TAG [, WITH])
$obj->count(TAG)
$obj->delete(TAG [, INDEX ])
$obj->fold([LENGTH])
$obj->get(TAG [, INDEX])
The lines are unfolded, but still terminated with a new-line (see "chomp")
$obj->print([FILEHANDLE])
$obj->replace(TAG, LINE [, INDEX ])
$obj->tags
$obj->unfold([TAG])
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.
SEE ALSO¶
This module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/.
AUTHORS¶
The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development.
Mail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by Peter Orbaek <poe@cit.dk>. Mail::Mailer and Mail::Send by Tim Bunce <Tim.Bunce@ig.co.uk>. For other contributors see ChangeLog.
LICENSE¶
Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2007 Mark Overmeer <perl@overmeer.net>.
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
2008-07-29 | perl v5.10.1 |