Courriel::Headers - The headers for an email part
my $email = Courriel->parse( text => ... );
my $headers = $email->headers;
print "$_\n" for $headers->get('Received');
This class represents the headers of an email.
Any sub part of an email can have its own headers, so every part has an associated object representing its headers. This class makes no distinction between top-level headers and headers for a sub part.
This class supports the following methods:
This method creates a new object by parsing a string. It accepts the following parameters:
The text to parse. This can either be a plain scalar or a reference to a scalar. If you pass a reference, the underlying scalar may be modified.
The line separator. This default to a "\r\n", but you can change it if necessary. Note that this only affects parsing, header objects are always output with RFC-compliant line endings.
Header parsing unfolds folded headers, and decodes any MIME-encoded values (as described in RFC 2047).
This method creates a new object. It accepts one parameter, headers, which should be an array reference of header names and values.
A given header key can appear multiple times.
This object does not (yet, perhaps) enforce RFC restrictions on repetition of certain headers.
Header order is preserved, per RFC 5322.
Given a header name, this returns a list of the values found for the header. Each occurrence of the header is returned as a separate value.
Given a header name and value, this adds the headers to the object. If any of the headers already have values in the object, then new values are added after the existing values, rather than at the end of headers.
This is like add(), but this pushes the headers onto the front of the internal headers array. This is useful if you are adding "Received" headers, which per RFC 5322, should always be added at the top of the headers.
Given a header name, this removes all instances of that header from the object.
A shortcut for calling remove() and add().
This returns a string representing the headers in the object. The values will be folded and/or MIME-encoded as needed.
The charset parameter specifies what character set to use for MIME-encoding non-ASCII values. This defaults to "utf8". The charset name must be one recognized by the Encode module.
MIME encoding is always done using the "B" (Base64) encoding, never the "Q" encoding.
Dave Rolsky <email@example.com>
This software is Copyright (c) 2011 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Courriel, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.