David O'Neill > Mail-Header-Generator > Mail::Header::Generator

Download:
Mail-Header-Generator-0.301.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.301   Source  

NAME ^

Mail::Header::Generator - Generate various email headers.

VERSION ^

Version 0.200

SYNOPSIS ^

    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',
    });

DESCRIPTION ^

This class generates RFC 5321/5322-compliant headers for use in email messages.

METHODS ^

Class Methods

new ( { args } )

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:

timestamp

A UNIX timestamp (from time()).

hostname

The local host name.

queue_id

The queue ID for the message you're generating these headers for.

Common Parameters

The following methods all take named parameters (as a hash reference). The following parameters are common:

header_name

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.

timestamp

UNIX timestamp (as generated by time()) for this header. If not provided, defaults to the current value of time().

hostname

The local host name.

Instance Methods

message_id ( ... )

Returns a string containing a Message-ID header.

Takes a hash reference containing values to use in generating this header. Valid keys are:

header_name

Defaults to 'Message-ID' if not provided.

timestamp
hostname

See top of this section for further details on these parameters.

received ( ... )

Returns a string containing a Received header.

Takes a hash reference containing values to use in generating this header. Valid keys are:

header_name

Defaults to 'Received' if not provided.

timestamp
hostname
product_name

String containing name of product responsible for adding this header. Will be added as a comment in the generated header if present.

protocol

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.

recipients

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.

relay_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.

relay_hostname

Hostname of relay address.

sender

The envelope sender address. If present, an 'envelope-sender' comment will be added to the generated header.

user

Local user that generated this message. Defaults to $ENV{USER} if not present and no relay address was provided.

See top of this section for further details on these parameters.

rfc2822_date ( ... )

Returns a string containing a RFC 2822 formatted date.

Takes a hash reference containing values to use in generating this header. Valid keys are:

header_name

No default if not provided.

timestamp

UNIX timestamp. Defaults to current value of time() if not provided.

date ( ... )

Returns a date header containing a RFC 2822 formatted date. This is a convenience wrapper around rfc2822_date().

Takes a hash reference containing values to use in generating this header. Valid keys are:

header_name

Defaults to 'Date' if not provided.

timestamp

UNIX timestamp. Defaults to current value of time() if not provided.

AUTHOR ^

Dave O'Neill, <dmo at roaringpenguin.com>

BUGS ^

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.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc Mail::Header::Generator

You can also look for information at:

ACKNOWLEDGEMENTS ^

received() and message_id() were originally implemented in MIMEDefang.

rfc2822_date() implementation based on one from Email::Date.

LICENSE AND COPYRIGHT ^

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.

syntax highlighting: