Email::Abstract
From PEPWiki
This article refers to the Perl module Email::Abstract.
- Read documentation: Email::Abstract
- Included in distribution: Email-Abstract
- View Open RT Tickets
Email::Abstract is supposed to provide a generic interface for handling email messages blessed into any of several classes.
The Email::Abstract interface is intentionally minimal, to help ensure that any representation of an email message can be interfaced with Email::Abstract.
my $message = MIME::Internet->new(...); # could be one of many classes
my $abstract = Email::Abstract->new($message);
my $subject = $abstract->get_header('Subject');
my $mail_message = $abstract->cast('Mail::Message');
The old interface was object-less and looked like this:
my $email_simple = Email::Simple->new($text); my $subject = Email::Abstract->get_header($email_simple, "Subject"); my $mail_message = Email::Abstract->cast($email_message, "Mail::Message");
Ideas
More Universal Methods
A number of useful methods remain to be added:
- stream_to - steam the message to a filehandle
- filehandle - provide an fh for the message as string (make sure if you get two, either document that they're synced or make sure they nevrr are)
- filename - provide a filename for a file containing the message
These came up on #email as things that would be useful when running a series of external analysis programs (virus scanners, etc.) on a message. All of these method could be implemented on top of the existing
MIME Methods
It would be nice to have a universal way to get at the basics of MIME parts. The methods would probably include:
- subparts - all the non-top-level parts of the message
- content_type - the content type of the part in "text/plain" form
This would probably have to be a subclass or mixin. Otherwise, on ends up guessing whether or not the passed-in Email::Simple object is really a MIME message.

