Email::Simple - Simple parsing of RFC2822 message format and headers
my $mail = Email::Simple->new($text); my $from_header = $mail->header("From"); my @received = $mail->header("Received"); $mail->header_set("From", 'Simon Cozens <email@example.com>'); my $old_body = $mail->body; $mail->body_set("Hello world\nSimon"); print $mail->as_string; # AND THAT'S ALL.
Email::Simple is the first deliverable of the "Perl Email Project", a reaction against the complexity and increasing bugginess of the
Mail::* modules. In contrast,
Email::* modules are meant to be simple to use and to maintain, pared to the bone, fast, minimal in their external dependencies, and correct.
Can you sum up plan 9 in layman's terms? It does everything Unix does only less reliably - kt
Methods are deliberately kept to a minimum. This is meant to be simple. No, I will not add method X. This is meant to be simple. Why doesn't it have feature Y? Because it's meant to be simple.
Parse an email from a scalar containing an RFC2822 formatted message, and return an object.
Returns a list of the contents of the given header.
If called in scalar context, will return the first header so named. I'm not sure I like that. Maybe it should always return a list. But it doesn't.
$mail->header_set($field, $line1, $line2, ...);
Sets the header to contain the given data. If you pass multiple lines in, you get multiple headers, and order is retained.
Returns the body text of the mail.
Sets the body text of the mail.
Returns the mail as a string, reconstructing the headers. Please note that header fields are kept in order if they are unique, but, for, instance, multiple "Received" headers will be grouped together. (This is in accordance with RFC2822, honest.)
Also, if you've added new headers with
header_set that weren't in the original mail, they'll be added to the end.
Email::Simple handles only RFC2822 formatted messages. This means you cannot expect it to cope well as the only parser between you and the outside world, say for example when writing a mail filter for invocation from a .forward file (for this we recommend you use Email::Filter anyway). For more information on this issue please consult RT issue 2478, http://rt.cpan.org/NoAuth/Bug.html?id=2478 .
Copyright 2004 by Casey West
Copyright 2003 by Simon Cozens
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Perl Email Project, http://pep.kwiki.org .