24 Jan 2009 03:04:04 UTC
- Distribution: Email-Simple
- Module version: 2.005
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (660 / 0 / 0)
- KwaliteeBus factor: 1
- License: perl_5
- Activity24 month
- Download (27.8KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
- PERL EMAIL PROJECT
- COPYRIGHT AND LICENSE
Email::Simple - simple parsing of RFC2822 message format and headers
my $email = Email::Simple->new($text); my $from_header = $email->header("From"); my @received = $email->header("Received"); $email->header_set("From", 'Simon Cozens <firstname.lastname@example.org>'); my $old_body = $email->body; $email->body_set("Hello world\nSimon"); print $email->as_string;
Email::Simpleis the first deliverable of the "Perl Email Project." The Email:: namespace was begun as a reaction against the increasing complexity and bugginess of Perl's existing email modules.
Email::*modules are meant to be simple to use and to maintain, pared to the bone, fast, minimal in their external dependencies, and correct.
my $email = Email::Simple->new($message, \%arg);
This method parses an email from a scalar containing an RFC2822 formatted message, and return an object.
$messagemay be a reference to a message string, in which case the string will be altered in place. This can result in significant memory savings.
If you want to create a message from scratch, you should use the plugin Email::Simple::Creator.
Valid arguments are:
header_class - the class used to create new header objects The named module is not 'require'-ed by Email::Simple!
my $header = $email->header_obj;
This method returns the object representing the email's header. For the interface for this object, see Email::Simple::Header.
This method substitutes the given new header object for the email's existing header object.
my @values = $email->header($header_name); my $first = $email->header($header_name);
In list context, this returns every value for the named header. In scalar context, it returns the first value for the named header.
$email->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.
my @header_names = $email->header_names;
This method returns the list of header names currently in the email object. These names can be passed to the
headermethod one-at-a-time to get header values. You are guaranteed to get a set of headers that are unique. You are not guaranteed to get the headers in any order at all.
For backwards compatibility, this method can also be called as headers.
my @headers = $email->header_pairs;
This method returns a list of pairs describing the contents of the header. Every other value, starting with and including zeroth, is a header name and the value following it is the header value.
Returns the body text of the mail.
Sets the body text of the mail.
Returns the mail as a string, reconstructing the headers.
This method returns the type of newline used in the email. It is an accessor only.
This returns the class used, by default, for header objects, and is provided for subclassing. The default default is Email::Simple::Header.
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.
This module is maintained by the Perl Email Project
Simon Cozens originally wrote Email::Simple in 2003. Casey West took over maintenance in 2004, and Ricardo SIGNES took over maintenance in 2006.
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.
Module Install Instructions
To install Email::Simple, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Email::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.