Mail::Header::Generator - Generate various email headers.
Version 0.200
use Mail::Header::Generator (); my $gen = Mail::Header::Generator->new({ hostname => 'foobar.example.com', }); # Generate Message-Id: header contents. $message_id will # contain: # <20100601142143.GA9035@foobar.example.com> # and use the hostname provided to the constructor. my $message_id = $gen->message_id({ timestamp => time(), queue_id => 'GA9035', }); # Generate a Received: header, including the Received: name. # Will result in something similar to: # Received: from localhost.localdomain ([127.0.0.1] localhost) # by foobar.example.com with ESMTP id o53JaiwX007246; Thu, 03 Jun 2010 15:37:51 -0400 my $received = $gen->received({ header_name => undef, relay_address => '127.0.0.1', relay_hostname => 'localhost', helo => 'localhost.localdomain', protocol => 'ESMTP', queue_id => 'o53JaiwX007246', });
This class generates RFC 5321/5322-compliant headers for use in email messages.
Constructs a new Mail::Header::Generator.
Takes a hash reference containing default arguments to be used for the various header-generation callbacks.
Commonly useful keys for default arguments are:
A UNIX timestamp (from time()).
The local host name.
The queue ID for the message you're generating these headers for.
The following methods all take named parameters (as a hash reference). The following parameters are common:
The name of this header. If this key exists and has a value of undef, the contents of the generated header will be returned with no name prefixed. If the key exists, and has a value, that value will be used as the name. If the key does not exist, the header will default to the same name as the method used to create it.
UNIX timestamp (as generated by time()) for this header. If not provided, defaults to the current value of time().
Returns a string containing a Message-ID header.
Takes a hash reference containing values to use in generating this header. Valid keys are:
Defaults to 'Message-ID' if not provided.
See top of this section for further details on these parameters.
Returns a string containing a Received header.
Defaults to 'Received' if not provided.
String containing name of product responsible for adding this header. Will be added as a comment in the generated header if present.
Protocol this message was received over. Should be "SMTP" or "ESMTP" for standards compliance. Will not be used in the generated header if not provided.
An array reference of recipient addresses. Currently, a 'for' tag will be created as part of the header only if the recipients array contains a single address.
String representation of IPv4 or IPv6 address that relayed this message to us. If not present, no 'from' section of the header will be created.
Hostname of relay address.
The envelope sender address. If present, an 'envelope-sender' comment will be added to the generated header.
Local user that generated this message. Defaults to $ENV{USER} if not present and no relay address was provided.
Returns a string containing a RFC 2822 formatted date.
No default if not provided.
UNIX timestamp. Defaults to current value of time() if not provided.
Returns a date header containing a RFC 2822 formatted date. This is a convenience wrapper around rfc2822_date().
Defaults to 'Date' if not provided.
Dave O'Neill, <dmo at roaringpenguin.com>
Please report any bugs or feature requests to bug-mail-header-generator at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mail-Header-Generator. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-mail-header-generator at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Mail::Header::Generator
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mail-Header-Generator
Search CPAN
http://search.cpan.org/dist/Mail-Header-Generator/
received() and message_id() were originally implemented in MIMEDefang.
rfc2822_date() implementation based on one from Email::Date.
Copyright 2010 Roaring Penguin Software
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 dated June, 1991 or at your option any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License is available in the source tree; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
To install Mail::Header::Generator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mail::Header::Generator
CPAN shell
perl -MCPAN -e shell install Mail::Header::Generator
For more information on module installation, please visit the detailed CPAN module installation guide.