man Email::Abstract () - Unified interface to mail representations

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

CWEmail::Abstract provides module writers with the ability to write representation-independent mail handling code. For instance, in the cases of CWMail::Thread or CWMail::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, CWEmail::Abstract can be used to perform certain simple operations on an object regardless of its underlying representation.

CWEmail::Abstract currently supports CWMail::Internet, CWMIME::Entity, CWMail::Message, CWEmail::Simple and CWEmail::MIME. Other representations are encouraged to create their own CWEmail::Abstract::* class by copying CWEmail::Abstract::EmailSimple. All modules installed under the CWEmail::Abstract hierarchy will be automatically picked up and used.

METHODS

This returns the value or list of values of the given header. This sets the CW$header header to the given one or more values.

get_body($obj)

This returns the body as a string. This changes the body of the email to the given string.

as_string($obj)

This returns the whole email as a string.

AUTHOR

Casey West, <casey@geeknest.com>

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.

SEE ALSO

http://pep.kwiki.org