NAME
Email::Abstract - Unified interface to mail representations
SYNOPSIS
my $message = Mail::Message->read($rfc822)
|| Email::Simple->new($rfc822)
|| Mail::Internet->new([split /\n/, $rfc822])
|| ...;
my $subject = Email::Abstract->get_header($message, "Subject");
Email::Abstract->set_header($message, "Subject", "My new subject");
my $body = Email::Abstract->get_body($message);
Email::Abstract->set_body($message, "Hello\nTest message\n");
$rfc822 = Email::Abstract->as_string($message);
my $mail_message = Email::Abstract->cast($message, "Mail::Message");
DESCRIPTION
Email::Abstract
provides module writers with the ability to write representation-independent mail handling code. For instance, in the cases of Mail::Thread
or Mail::ListDetector
, a key part of the code involves reading the headers from a mail object. Where previously one would either have to specify the mail class required, or to build a new object from scratch, Email::Abstract
can be used to perform certain simple operations on an object regardless of its underlying representation.
Email::Abstract
currently supports Mail::Internet
, MIME::Entity
, Mail::Message
, Email::Simple
and Email::MIME
. Other representations are encouraged to create their own Email::Abstract::*
class by copying Email::Abstract::EmailSimple
. All modules installed under the Email::Abstract
hierarchy will be automatically picked up and used.
METHODS
get_header($obj, $header)
This returns the value or list of values of the given header.
get_header($obj, $header, @lines)
This sets the $header
header to the given one or more values.
get_body($obj)
This returns the body as a string.
set_body($obj, $string)
This changes the body of the email to the given string.
as_string($obj)
This returns the whole email as a string.
AUTHOR
Simon Cozens, <simon@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2004 by Simon Cozens
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.