Email-Simple-2.201/000755 000766 000766 00000000000 12133267623 013757 5ustar00rjbsrjbs000000 000000 Email-Simple-2.201/Changes000644 000766 000766 00000011267 12133267115 015255 0ustar00rjbsrjbs000000 000000 Revision history for Perl extension Email::Simple. 2.201 2013-04-16 no changes 2.200_01 2013-04-09 preserve the original header layout unless changed 2.103 2013-04-09 fix a bug in header unfolding where "0\n 1" could be unfolded to "01" 2.102 2012-07-13 recognize crlf correctly even if there is no body (thanks, Christian Walde) 2.101 2011-12-23 remove instruction to use ::Creator instead of just ->create documentation improvements (thanks, Michael Stevens) 2.100 2009-11-03 merge Email-Simple-Creator into Email-Simple distribution 2.005 2009-01-22 add repository metadata 2.004 2008-06-25 publicize default_header_class method remove the long-deprecated Headers.pm 2.003 2007-07-19 improve tests, for 5.5 compat remove conditional circular prereq on Email::MIME, replace it with a warning and delay 2.002 2007-07-14 change initialization order to unbreak Email::MIME do not return ->body from ->body_set to simplify subclass behavior 2.001 2007-07-13 fix t/perl-minver.t to properly skip if T::MV not installed retroactively set 2.000 release date! 2.000 2007-07-13 huge improvement to speed of bodyless message parsing pointed out by Dan Dascalescu; thanks! more documentation of header class new Header crlf defaults to real CRLF fix tests to avoid requiring 5.6 1.999 2007-03-20 fix bug 25496: deletion of headers affected the wrong range, sometimes deleting too many headers -- thanks, Nicholas Oxhoej! fix bug 24922: errant space in last header of CRLF-delim email thanks, Barry Downes and Alex Vandiver 1.998 2007-02-07 MAJOR REFACTORING OF GUTS If you run Email::MIME, you MUST be running Email::MIME 1.857 or better. require Email::MIME 1.857 in Makefile.PL only if an older version is already installed boldly moving forward with refactored headers and Email::Simple:::Header greatly reduce memory footprint add crlf method to allow other modules to avoid ->{mycrlf} fix broken header-junk test 1.996 2006-11-27 - do not wrap Content-Type field; it can cause Outlook to go nuts while this is a special case, it does not make E::S incorrect, as folding long headers is allowed (for aesthetics) and not mandated 1.995 2006-10-19 - tentative refactoring of headers 1.992 2006-10-05 - fix a number of bugs when setting multiple headers, which would often refuse to set more values than were currently present - added a test for prepending (rather than appending) headers; while E::S does not yet support this, the header behavior will be easier to replace in future versions, and this is a forward-looking test 1.990 2006-09-05 - ->header('foo') returns false if there is no foo header (formerly '') - croak if an undef value is passed to new() 1.980 2006-08-17 - fix _fold() to add a missing line ending [RT #20764] (Brian Cassidy) 1.970 2006-08-17 - bring ->headers method into Email::Simple - ->header_names and ->header_pairs 1.96 2006-07-28 - output headers in predictable order - give tests more meaningful names - improved test coverage 1.95 2006-07-21 - update PEP url - reorganize dist 1.94 2006-07-03 - Fix folding of long headers with \r as line ending (thanks Adam Worrall) - add tests for message with no body 1.92 2004-11-11 - Update dependencies. - Update test suite to support proper Test::More syntax. 1.91 2004-10-27 - Tests use alarm(), skip those tests on MSWin32. - body() is initialized to '' if it isn't defined. - Author changes. 1.9 Fix our own damned line-wrapping. 1.8 Do our own damned line-wrapping 1.7 Sample, don't assume, what CRLF we're using. This means that mail with funny crlfs is round-trippable. 1.61 fixes to test suite. there was a 5.6ish open my $fh which led to test failures under 5.00503 1.6 - fixes to test suite. We were using no_plan which fails on older versions of Test::Harness 1.5 - fixes more warnings during ->as_string calls Documents more strongly that Email::Simple is intended for use with RFC2822 messages only 1.4 - fixes a warning emitted during ->as_string calls fix for header unfolding 1.3 - Many fixes from Richard Clamp 1.2 - Text::Wrapper->Text::Wrap 0.01 Thu Feb 13 15:07:01 2003 - original version; created by h2xs 1.22 with options -b 5.5.3 -AX -n Email::Simple Email-Simple-2.201/lib/000755 000766 000766 00000000000 12133267623 014525 5ustar00rjbsrjbs000000 000000 Email-Simple-2.201/LICENSE000644 000766 000766 00000047371 11111624535 014772 0ustar00rjbsrjbs000000 000000 Terms of Perl itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" ---------------------------------------------------------------------------- The General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ---------------------------------------------------------------------------- The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Email-Simple-2.201/Makefile.PL000644 000766 000766 00000002111 11274201233 015712 0ustar00rjbsrjbs000000 000000 use strict; use ExtUtils::MakeMaker; use 5.00503; # This is so stupid! We need to make sure that Email::MIME, a downstream # module, is running a version that doesn't screw around with the guts of # Email::Simple. if (eval { require Email::MIME }) { unless (eval { Email::MIME->VERSION(1.857) }) { warn < 'Email::Simple', VERSION_FROM => 'lib/Email/Simple.pm', (eval { ExtUtils::MakeMaker->VERSION(6.21) } ? (LICENSE => 'perl') : ()), PREREQ_PM => { 'Test::More' => '0.47', 'Email::Date::Format' => 0, }, (eval { ExtUtils::MakeMaker->VERSION(6.46) } ? (META_MERGE => { resources => { Repository => 'http://github.com/rjbs/email-simple' } }) : () ), ); Email-Simple-2.201/MANIFEST000644 000766 000766 00000001541 12133267623 015111 0ustar00rjbsrjbs000000 000000 Changes lib/Email/Simple.pm lib/Email/Simple/Creator.pm lib/Email/Simple/Header.pm LICENSE Makefile.PL MANIFEST README t/badly-folded.t t/basic.t t/create.t t/ct-header.t t/folding.t t/header-case.t t/header-junk.t t/header-many.t t/header-names.t t/header-new.t t/header-pairs.t t/header-prepend.t t/header-space.t t/long-msgid.t t/many-repeats.t t/no-body.t t/perl-minver.t t/pod-coverage.t t/pod.t t/preserve-linefeed.t t/test-mails/badly-folded t/test-mails/badly-folded-noindent t/test-mails/josey-fold t/test-mails/josey-nobody t/test-mails/josey-nobody-blank t/test-mails/josey-nofold t/test-mails/junk-in-header t/test-mails/long-msgid t/test-mails/many-repeats t/undef-message.t t/unit.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Email-Simple-2.201/META.json000644 000766 000766 00000001703 12133267623 015401 0ustar00rjbsrjbs000000 000000 { "abstract" : "unknown", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.6501, CPAN::Meta::Converter version 2.130880", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Email-Simple", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Email::Date::Format" : "0", "Test::More" : "0.47" } } }, "release_status" : "stable", "resources" : { "x_Repository" : "http://github.com/rjbs/email-simple" }, "version" : "2.201" } Email-Simple-2.201/META.yml000644 000766 000766 00000001024 12133267623 015225 0ustar00rjbsrjbs000000 000000 --- abstract: unknown author: - unknown build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.6501, CPAN::Meta::Converter version 2.130880' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Email-Simple no_index: directory: - t - inc requires: Email::Date::Format: 0 Test::More: 0.47 resources: x_Repository: http://github.com/rjbs/email-simple version: 2.201 Email-Simple-2.201/README000644 000766 000766 00000005542 11675151544 014651 0ustar00rjbsrjbs000000 000000 NAME Email::Simple - Simple parsing of RFC2822 message format and headers SYNOPSIS my $mail = Email::Simple->new($text); my $from_header = $mail->header("From"); my @received = $mail->header("Received"); $mail->header_set("From", 'Simon Cozens '); my $old_body = $mail->body; $mail->body_set("Hello world\nSimon"); print $mail->as_string; # AND THAT'S ALL. DESCRIPTION "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 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. new Parse an email from a scalar containing an RFC2822 formatted message, and return an object. header 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. header_set $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. body Returns the body text of the mail. body_set Sets the body text of the mail. as_string 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. CAVEATS 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 . PERL EMAIL PROJECT This module is maintained by the Perl Email Project http://emailproject.perl.org/wiki/Email::Simple COPYRIGHT AND LICENSE 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. Email-Simple-2.201/t/000755 000766 000766 00000000000 12133267623 014222 5ustar00rjbsrjbs000000 000000 Email-Simple-2.201/t/badly-folded.t000644 000766 000766 00000001557 11111624535 016737 0ustar00rjbsrjbs000000 000000 #!perl -w use strict; use Test::More tests => 5; # This time, with folding! use_ok("Email::Simple"); sub read_file { local $/; local *FH; open FH, shift or die $!; return } { my $mail_text = read_file("t/test-mails/badly-folded"); my $msg1 = Email::Simple->new($mail_text); my $msg2 = Email::Simple->new($msg1->as_string); is( $msg2->header('X-Sieve'), 'CMU Sieve 2.2', "still have X-Sieve header after round trip", ); } { my $mail_text = read_file("t/test-mails/badly-folded-noindent"); my $msg1 = Email::Simple->new($mail_text); is($msg1->header('Bar'), 'Bar', "got first header ok"); is( $msg1->header('Badly-Folded'), 'This header is badly folded because even though it goes onto the second line, it has no indent.', "got badly folded, middle header OK", ); is($msg1->header('Foo'), 'Foo', "got final header ok"); } Email-Simple-2.201/t/basic.t000644 000766 000766 00000005177 11111624535 015474 0ustar00rjbsrjbs000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 37; sub read_file { local $/; local *FH; open FH, shift or die $!; return } use_ok("Email::Simple"); # Very basic functionality test my $file_contents = read_file("t/test-mails/josey-nofold"); for my $mail_text ($file_contents, \$file_contents) { my $mail_text_string = ref $mail_text ? $$mail_text : $mail_text; my $mail = Email::Simple->new($mail_text); isa_ok($mail, "Email::Simple"); my $old_from; is($old_from = $mail->header("From"), 'Andrew Josey ', "We can get a header"); my $sc = 'Simon Cozens '; is($mail->header_set("From", $sc), $sc, "Setting returns new value"); is($mail->header("From"), $sc, "Which is consistently returned"); is( $mail->header("Bogus"), undef, "missing header returns undef" ); # Put andrew back: $mail->header_set("From", $old_from); my $body; like($body = $mail->body, qr/Austin Group Chair/, "Body has sane stuff in it"); my $old_body; my $hi = "Hi there!\n"; $mail->body_set($hi); is($mail->body, $hi, "Body can be set properly"); my $bye = "Goodbye!\n"; $mail->body_set(\$bye); is($mail->body, $bye, "Body can be set with a ref to a string, too"); $mail->body_set($body); is( $mail->as_string, $mail_text_string, "Good grief, it's round-trippable" ); is( Email::Simple->new($mail->as_string)->as_string, $mail_text_string, "Good grief, it's still round-trippable" ); { my $email = Email::Simple->new($mail->as_string); $email->body_set(undef); is( $email->body, '', "setting body to undef makes ->body return ''", ); $email->body_set(0); is( $email->body, '0', "setting body to false string makes ->body return that", ); $email->header_set('Previously-Unknown' => 'wonderful species'); is( $email->header('Previously-Unknown'), 'wonderful species', "we can add headers that were previously not in the message", ); like( $email->as_string, qr/Previously-Unknown: wonderful species/, "...and the show up in the stringification", ); } { # With nasty newlines my $nasty = "Subject: test\n\rTo: foo\n\r\n\rfoo\n\r"; my $mail = Email::Simple->new($nasty); my ($pos, $mycrlf) = Email::Simple->_split_head_from_body(\$nasty); is($pos, 26, "got proper header-end offset"); is($mycrlf, "\n\r", "got proper line terminator"); my $test = $mail->as_string; is($test, $nasty, "Round trip that too"); is(Email::Simple->new($mail->as_string)->as_string, $nasty, "... twice"); } } Email-Simple-2.201/t/create.t000644 000766 000766 00000005500 11274201233 015640 0ustar00rjbsrjbs000000 000000 use strict; use warnings; use Test::More tests => 25; use_ok 'Email::Simple'; use_ok 'Email::Simple::Creator'; sub tested_email { my ($name, %args) = @_; my $email = Email::Simple->create(%args); isa_ok $email, 'Email::Simple', "$name message"; my $string = $email->as_string; my @last_two = ( substr($string, -2, 1), substr($string, -1, 1), ); is( sprintf("%03u %03u", map { ord } @last_two), '013 010', "$name: stringified message ends with std CRLF" ); unlike( $email->as_string, qr/(? body => $body, header => [ Subject => 'all tests and no code make rjbs something something', From => 'jack', To => 'sissy', ], ); } { # should get an automatic date header my $email = tested_email(auto_date => header => [ To => 'you', ], body => 'test test', ); like( $email->header('date'), qr/^[A-Z][a-z]{2},/, # lame -- rjbs, 2007-02-23 "we got an auto-generated date header starting with a DOW", ); } { # who needs args? (why is this legal? who knows -- rjbs, 2007-07-13) my $email = tested_email('argless'); like( $email->header('date'), qr/^[A-Z][a-z]{2},/, # lame -- rjbs, 2007-02-23 "we got an auto-generated date header starting with a DOW", ); } { # no need to add CRLF if it's there my $email = tested_email(has_crlf => header => [ To => 'you', ], body => "test test\x0d\x0a", ); } { # no date header, we provided one my $email = tested_email(has_date => header => [ Date => 'testing', 'X-Header' => 'one', 'X-Header' => 'two', 'X-Header' => 'three', ], body => q[This is a multi- line message.], ); my $expected = <<'END_MESSAGE'; Date: testing X-Header: one X-Header: two X-Header: three This is a multi- line message. END_MESSAGE my $string = $email->as_string; $string =~ s/\x0d\x0a/\n/gsm; is( $string, $expected, "we got just the string we expected", ); } { # a few headers with false values my $email = tested_email(falsies => header => [ Date => undef, Zero => 0, Empty => '', ], body => "The body is uninteresting.", ); is_deeply( [ $email->header_pairs ], [ Date => '', Zero => 0, Empty => '', ], "got the false headers back we want", ); my $expected = <<'END_MESSAGE'; Date: Zero: 0 Empty: The body is uninteresting. END_MESSAGE my $string = $email->as_string; $string =~ s/\x0d\x0a/\n/gsm; is( $string, $expected, "we got just the string we expected", ); } Email-Simple-2.201/t/ct-header.t000644 000766 000766 00000001403 12133267042 016234 0ustar00rjbsrjbs000000 000000 #!perl -w use strict; use Test::More tests => 2; use Email::Simple; # This asinine exception is made for Lotus Notes sending to Outlook. When # reconstituting this value (created by Lotus Notes), Outlook becomes unable to # locate the MIME boundary. The proper fix would be to note structure fields # and analyze and reformat them correctly. Fat chance. -- rjbs, 2006-11-27 my $ct_text = qq{Content-Type: multipart/alternative; boundary="=_alternative 0065F3338525722E_="\n}; { my $count = my @lines = split /\n/, $ct_text; is($count, 1, "we start with one line (Content-Type header)"); } { my $email = Email::Simple->new($ct_text); my $count = my @lines = split /\n/, $email->as_string; is($count, 1, "we end with one, because C-T doesn't wrap"); } Email-Simple-2.201/t/folding.t000644 000766 000766 00000002416 12131022122 016011 0ustar00rjbsrjbs000000 000000 #!perl -w use strict; use Test::More tests => 6; # This time, with folding! use_ok("Email::Simple"); sub read_file { local $/; local *FH; open FH, shift or die $!; return } my $mail_text = read_file("t/test-mails/josey-fold"); my $mail = Email::Simple->new($mail_text); isa_ok($mail, "Email::Simple"); is($mail->header("References"), q{<200211120937.JAA28130@xoneweb.opengroup.org> <1021112125524.ZM7503@skye.rdg.opengroup.org> <3DD221BB.13116D47@sun.com>}, "References header checks out"); is($mail->header("reFerEnceS"), q{<200211120937.JAA28130@xoneweb.opengroup.org> <1021112125524.ZM7503@skye.rdg.opengroup.org> <3DD221BB.13116D47@sun.com>}, "References header checks out with case folding"); is_deeply([$mail->header("Received")], [ 'from mailman.opengroup.org ([192.153.166.9]) by deep-dark-truthful-mirror.pad with smtp (Exim 3.36 #1 (Debian)) id 18Buh5-0006Zr-00 for ; Wed, 13 Nov 2002 10:24:23 +0000', '(qmail 1679 invoked by uid 503); 13 Nov 2002 10:10:49 -0000'], "And the received headers are folded gracefully, and multiple headers work"); { my $text = <<'END'; Fold-1: 1 2 3 Fold-2: 0 1 2 Body END my $email = Email::Simple->new($text); is($email->header('Fold-2'), '0 1 2', "we unfold with a false start string"); } Email-Simple-2.201/t/header-case.t000644 000766 000766 00000000434 11111624535 016543 0ustar00rjbsrjbs000000 000000 use Test::More tests => 1; use Email::Simple; my $m = Email::Simple->new("Foo-Bar: Baz\n\ntest\n"); $m->header_set("Foo-bar", "quux"); is($m->as_string, "Foo-Bar: quux test\n", "Only one header this time"); Email-Simple-2.201/t/header-junk.t000644 000766 000766 00000000537 11111624535 016603 0ustar00rjbsrjbs000000 000000 #!perl use strict; use Test::More tests => 3; use_ok('Email::Simple'); sub read_file { local $/; local *FH; open FH, shift or die $!; return } my $mail_text = read_file("t/test-mails/junk-in-header"); my $mail = Email::Simple->new($mail_text); isa_ok($mail, "Email::Simple"); unlike($mail->as_string, qr/linden/, "junk droped from header"); Email-Simple-2.201/t/header-many.t000644 000766 000766 00000005731 11111624535 016601 0ustar00rjbsrjbs000000 000000 #!perl use strict; use Test::More tests => 16; use_ok('Email::Simple'); my $email_text = <new($email_text); isa_ok($email, "Email::Simple"); is_deeply( [ $email->header('alpha') ], [ 'this header comes first', 'this header comes third' ], "we get both values, in order, for a multi-entry header", ); is_deeply( [ $email->header_pairs ], [ Alpha => 'this header comes first', Bravo => 'this header comes second', Alpha => 'this header comes third', ], "and we get everything in order for header_pairs", ); my @rv = $email->header_set(alpha => ('header one', 'header three')); is_deeply( \@rv, [ 'header one', 'header three' ], "header_set in list context returns all set values", ); is_deeply( [ $email->header('alpha') ], [ 'header one', 'header three' ], "headers are replaced in order", ); is_deeply( [ $email->header_pairs ], [ Alpha => 'header one', Bravo => 'this header comes second', Alpha => 'header three', ], "and we still get everything in order for header_pairs", ); my $rv = $email->header_set(alpha => qw(h1 h3 h4)); is($rv, 'h1', "header_set in scalar context returns first set header"); is_deeply( [ $email->header('alpha') ], [ qw(h1 h3 h4) ], "headers are replaced in order, extras appended", ); is_deeply( [ $email->header_pairs ], [ Alpha => 'h1', Bravo => 'this header comes second', Alpha => 'h3', alpha => 'h4', ], "and we still get everything in order for header_pairs", ); $email->header_set(alpha => 'one is the loneliest header'); is_deeply( [ $email->header('alpha') ], [ 'one is the loneliest header' ], "and we drop down to one value for alpha header ok", ); is_deeply( [ $email->header_pairs ], [ Alpha => 'one is the loneliest header', Bravo => 'this header comes second', ], "and we still get everything in order for header_pairs", ); $email->header_set(Gamma => 'gammalon'); is_deeply( [ $email->header_pairs ], [ Alpha => 'one is the loneliest header', Bravo => 'this header comes second', Gamma => 'gammalon', ], "a third header goes in at the end", ); $email->header_set(alpha => ('header one', 'header omega')); is_deeply( [ $email->header_pairs ], [ Alpha => 'header one', Bravo => 'this header comes second', Gamma => 'gammalon', alpha => 'header omega', ], "and re-adding to the previously third header puts it fourth", ); $email->header_set('Bravo'); is_deeply( [ $email->header_pairs ], [ Alpha => 'header one', Gamma => 'gammalon', alpha => 'header omega', ], "Bravo header gets completely removed", ); $email->header_set('Omega'); is_deeply( [ $email->header_pairs ], [ Alpha => 'header one', Gamma => 'gammalon', alpha => 'header omega', ], "nothing weird happens when deleting absent headers", ); Email-Simple-2.201/t/header-names.t000644 000766 000766 00000001173 11111624535 016734 0ustar00rjbsrjbs000000 000000 use Test::More tests => 9; use strict; $^W = 1; use_ok 'Email::Simple'; my @emails; push @emails, Email::Simple->new(<<'__MESSAGE__'); From: casey@geeknest.com To: drain@example.com Subject: Message in a bottle __MESSAGE__ push @emails, Email::Simple->new(<<'__MESSAGE__'); From: casey@geeknest.com To: drain@example.com Subject: Message in a bottle subject: second subject! HELP! __MESSAGE__ for my $email (@emails) { for my $method ('header_names', 'headers') { can_ok($email, $method); is_deeply( [ qw(From To Subject) ], [ $email->$method() ], "have expected headers (via $method)" ); } } Email-Simple-2.201/t/header-new.t000644 000766 000766 00000001302 11111624535 016414 0ustar00rjbsrjbs000000 000000 use strict; use Test::More tests => 7; # This test could test all manner of Email::Simple::Header stuff, but is mostly # just here specifically to test construction and sanity of result with both a # string AND a reference to it. -- rjbs, 2006-11-29 BEGIN { use_ok('Email::Simple::Header'); } my $header_string = <<'END_HEADER'; Foo: 1 Foo: 2 Bar: 3 Baz: 1 END_HEADER for my $header_param ($header_string, \$header_string) { my $head = Email::Simple::Header->new($header_param); isa_ok($head, 'Email::Simple::Header'); is_deeply( [ $head->header('foo') ], [ 1, 2 ], "multi-value header", ); is_deeply( scalar $head->header('foo'), 1, "single-value header", ); } Email-Simple-2.201/t/header-pairs.t000644 000766 000766 00000001600 11111624535 016742 0ustar00rjbsrjbs000000 000000 use Test::More tests => 3; use strict; $^W = 1; use_ok 'Email::Simple'; my $email = Email::Simple->new(<<'__MESSAGE__'); From: casey@geeknest.example.com X-Your-Face: your face is your face To: drain@example.com X-Your-Face: your face is my face X-Your-Face: from california Reply-To: xyzzy@plugh.example.net X-Your-Face: to the new york islface Subject: Message in a bottle HELP! __MESSAGE__ can_ok $email, 'header_names'; my @header_pairs = $email->header_pairs; is_deeply( \@header_pairs, [ 'From', 'casey@geeknest.example.com', 'X-Your-Face', 'your face is your face', 'To', 'drain@example.com', 'X-Your-Face', 'your face is my face', 'X-Your-Face', 'from california', 'Reply-To', 'xyzzy@plugh.example.net', 'X-Your-Face', 'to the new york islface', 'Subject', 'Message in a bottle', ], "header pairs came out properly", ); Email-Simple-2.201/t/header-prepend.t000644 000766 000766 00000002600 11111624535 017262 0ustar00rjbsrjbs000000 000000 #!perl use strict; use Test::More tests => 4; # This test is not here to encourage you to muck about in the object guts, but # to provide a test for when Email::Simple has a way to provide optional # extended header munging. use_ok('Email::Simple'); my $email_text = <new($email_text); isa_ok($email, "Email::Simple"); sub Email::Simple::header_prepend { my ($self, $field, @values) = @_; for my $value (reverse @values) { unshift @{ $self->header_obj->{headers} }, $field, $value; } } $email->header_prepend(Alpha => 'this header comes firstest'); is_deeply( [ $email->header_pairs ], [ Alpha => 'this header comes firstest', Alpha => 'this header comes first', Bravo => 'this header comes second', Alpha => 'this header comes third', ], "we can prepend an existing header", ); $email->header_prepend('Zero' => 'this header comes zeroeth', 'and 0+1th'); is_deeply( [ $email->header_pairs ], [ Zero => 'this header comes zeroeth', Zero => 'and 0+1th', Alpha => 'this header comes firstest', Alpha => 'this header comes first', Bravo => 'this header comes second', Alpha => 'this header comes third', ], "we can prepend mutiply, too, and to a new header", ); Email-Simple-2.201/t/header-space.t000644 000766 000766 00000001011 12000015130 016672 0ustar00rjbsrjbs000000 000000 #!perl -T use strict; use Test::More tests => 12; use Email::Simple; my @crlf = ( 'CR' => "\x0d", 'CRLF' => "\x0d\x0a", 'LF' => "\x0a", 'LFCR' => "\x0a\x0d", ); while (my ($name, $eol) = splice @crlf, 0, 2) { my $m = Email::Simple->new("Foo-Bar: Baz${eol}${eol}test${eol}"); is($m->header('foo-bar'), 'Baz', "no spaces trail with $name"); is($m->crlf, $eol, "correctly detected crlf value"); $m = Email::Simple->new("Foo-Bar: Baz${eol}"); is($m->crlf, $eol, "correctly detected crlf value"); } Email-Simple-2.201/t/long-msgid.t000644 000766 000766 00000000664 11111624535 016447 0ustar00rjbsrjbs000000 000000 #!perl -w use strict; use Test::More tests => 3; # This time, with folding! use_ok("Email::Simple"); sub read_file { local $/; local *FH; open FH, shift or die $!; return } my $mail_text = read_file("t/test-mails/long-msgid"); my $mail = Email::Simple->new($mail_text); isa_ok($mail, "Email::Simple"); SKIP: { skip "no alarm() on win32", 1 if $^O =~ /mswin32/i; alarm 5; ok($mail->as_string(), "Doesn't hang"); }; Email-Simple-2.201/t/many-repeats.t000644 000766 000766 00000001047 11111624535 017010 0ustar00rjbsrjbs000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 4; sub read_file { local $/; local *FH; open FH, shift or die $!; return } use_ok("Email::Simple"); # Very basic functionality test my $mail_text = read_file("t/test-mails/many-repeats"); my $mail = Email::Simple->new($mail_text); isa_ok($mail, "Email::Simple"); my $body = $mail->body; $mail->body_set($body); is($mail->as_string, $mail_text, "Good grief, it's round-trippable"); is(Email::Simple->new($mail->as_string)->as_string, $mail_text, "Good grief, it's still round-trippable"); Email-Simple-2.201/t/no-body.t000644 000766 000766 00000000736 11111624535 015756 0ustar00rjbsrjbs000000 000000 #!perl -w use strict; use Test::More tests => 5; # This time, with folding! use_ok("Email::Simple"); sub read_file { local $/; local *FH; open FH, shift or die $!; return } for ('', '-blank') { my $mail_text = read_file("t/test-mails/josey-nobody$_"); my $mail = Email::Simple->new($mail_text); isa_ok($mail, "Email::Simple"); is( $mail->header('From'), 'Andrew Josey ', 'correct From header on bodyless message', ); } Email-Simple-2.201/t/perl-minver.t000644 000766 000766 00000000371 11274201233 016636 0ustar00rjbsrjbs000000 000000 #!perl use strict; use Test::More; eval { require Test::MinimumVersion; Test::MinimumVersion->VERSION(0.003); Test::MinimumVersion->import; }; plan skip_all => "this test requires Test::MinimumVersion" if $@; all_minimum_version_ok(5.006); Email-Simple-2.201/t/pod-coverage.t000644 000766 000766 00000000407 12131022122 016740 0ustar00rjbsrjbs000000 000000 #!perl use Test::More; eval "use Test::Pod::Coverage 1.08"; plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::CountParents', trustme => [ qw(headers) ], }); Email-Simple-2.201/t/pod.t000644 000766 000766 00000000211 12131022122 015140 0ustar00rjbsrjbs000000 000000 #!perl use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); Email-Simple-2.201/t/preserve-linefeed.t000644 000766 000766 00000000547 11111624535 020013 0ustar00rjbsrjbs000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 3; use_ok( 'Email::Simple' ); my $original = <<'EOM'; subject: =?utf-8?B?ZGVsLmljaW8udXMvbmV0d29yay9qb2VlIC0gW2Zyb20gbWlqaXRdIEJMQiBFY2MgMw==?= content-type: text/plain empty body EOM my $mail = Email::Simple->new( $original ); isa_ok( $mail, 'Email::Simple' ); is( $mail->as_string, $original ); Email-Simple-2.201/t/test-mails/000755 000766 000766 00000000000 12133267623 016304 5ustar00rjbsrjbs000000 000000 Email-Simple-2.201/t/undef-message.t000644 000766 000766 00000000332 11111624535 017122 0ustar00rjbsrjbs000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 3; use_ok("Email::Simple"); eval { Email::Simple->new }; ok( $@, 'throws an error' ); like( $@, qr/unable to parse undefined message/i, 'throws sane error' ); Email-Simple-2.201/t/unit.t000644 000766 000766 00000001705 11111624535 015363 0ustar00rjbsrjbs000000 000000 #!/usr/bin/perl # This is a series of unit tests to ensure that things do what I think # they do. use strict; use Email::Simple; package Email::Simple; use Test::More tests => 8; # Simple "email", no body my $text = "a\nb\nc\n"; my ($pos, $crlf) = Email::Simple->_split_head_from_body(\$text); is($pos, undef, "no body position!"); is($crlf, "\n", 'and \n is the crlf'); # Simple "email", properly formed $text = "a\n\nb\n"; ($pos, $crlf) = Email::Simple->_split_head_from_body(\$text); is($pos, 3, "body starts at pos 3"); is($crlf, "\n", 'and \n is the crlf'); # Simple "email" with blank lines $text = "a\n\nb\nc\n"; ($pos, $crlf) = Email::Simple->_split_head_from_body(\$text); is($pos, 3, "body starts at pos 3"); is($crlf, "\n", 'and \n is the crlf'); # Blank line as first line in email $text = "a\n\n\nb\nc\n"; ($pos, $crlf) = Email::Simple->_split_head_from_body(\$text); is($pos, 3, "body starts at pos 3"); is($crlf, "\n", 'and \n is the crlf'); Email-Simple-2.201/t/test-mails/badly-folded000644 000766 000766 00000003446 11111624535 020556 0ustar00rjbsrjbs000000 000000 Return-Path: Received: from murder ([unix socket]) (authenticated user=adam bits=0) by mail1.foo.com (Cyrus v2.2.12-OS X 10.4.0) with LMTPA; Tue, 25 Oct 2005 07:26:59 -0400 X-Sieve: CMU Sieve 2.2 X-Original-To: adam@mail1.internal.foo.com Delivered-To: adam@mail1.internal.foo.com Received: from localhost (localhost [127.0.0.1]) by mail1.foo.com (Postfix) with ESMTP id C24ABADEA15 for ; Tue, 25 Oct 2005 07:26:58 -0400 (EDT) Received: from mail1.foo.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20330-05 for ; Tue, 25 Oct 2005 07:26:55 -0400 (EDT) Received: from mta.internal.foo.com (mta.internal.foo.com [0.0.0.0]) by mail1.foo.com (Postfix) with ESMTP id 1D919ADE9FE for ; Tue, 25 Oct 2005 07:26:55 -0400 (EDT) Received: from [0.0.0.0] ([0.0.0.0]) (authenticated bits=0) by mta.internal.foo.com (8.12.8/8.12.8) with ESMTP id j9PBQoCT026374 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Tue, 25 Oct 2005 07:26:53 -0400 Message-ID: Date: Tue, 25 Oct 2005 07:30:17 -0400 From: x Reply-To: x@foo.com User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Adam Worrall Subject: My subject X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/mixed; boundary="------------040701020305070002070307" X-PMX-Version: 4.6.1.107272 X-Virus-Scanned: by amavisd-new at foo.com This is a multi-part message in MIME format. --------------040701020305070002070307 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Blah blah --------------040701020305070002070307-- Email-Simple-2.201/t/test-mails/badly-folded-noindent000644 000766 000766 00000000224 11111624535 022361 0ustar00rjbsrjbs000000 000000 Bar: Bar Badly-Folded: This header is badly folded because even though it goes onto the second line, it has no indent. Foo: Foo This is the body! Email-Simple-2.201/t/test-mails/josey-fold000644 000766 000766 00000010620 11111624535 020273 0ustar00rjbsrjbs000000 000000 From mail-miner-10529@localhost Wed Dec 18 12:07:55 2002 Received: from mailman.opengroup.org ([192.153.166.9]) by deep-dark-truthful-mirror.pad with smtp (Exim 3.36 #1 (Debian)) id 18Buh5-0006Zr-00 for ; Wed, 13 Nov 2002 10:24:23 +0000 Received: (qmail 1679 invoked by uid 503); 13 Nov 2002 10:10:49 -0000 Resent-Date: 13 Nov 2002 10:10:49 -0000 Date: Wed, 13 Nov 2002 10:06:51 GMT From: Andrew Josey Message-Id: <1021113100650.ZM12997@skye.rdg.opengroup.org> In-Reply-To: Joanna Farley's message as of Nov 13, 9:56am. References: <200211120937.JAA28130@xoneweb.opengroup.org> <1021112125524.ZM7503@skye.rdg.opengroup.org> <3DD221BB.13116D47@sun.com> X-Mailer: Z-Mail (5.0.0 30July97) To: austin-group-l@opengroup.org Subject: Re: Defect in XBD lround MIME-Version: 1.0 Resent-Message-ID: Resent-To: austin-group-l@opengroup.org Resent-From: austin-group-l@opengroup.org X-Mailing-List: austin-group-l:archive/latest/4823 X-Loop: austin-group-l@opengroup.org Precedence: list Resent-Sender: austin-group-l-request@opengroup.org Content-Type: text/plain; charset=us-ascii Joanna, All Thanks. I got the following response from Fred Tydeman. C99 Defect Report (DR) 240 covers this. The main body of C99 (7.12.9.7) says range error, while Annex F (F.9.6.7 and F.9.6.5) says "invalid" (domain error). The result was to change 7.12.9.7 to allow for either range or domain error. The preferred error is domain error (so as match Annex F). So, no need to change XBD. regards Andrew On Nov 13, 9:56am in "Re: Defect in XBD lr", Joanna Farley wrote: > Sun's expert in this area after some discussions with a colleague > outside of Sun concluded that for lround, to align with both C99 and SUS > changes of the following form were necessary: > > + If x is +/-Inf/NaN, a domain error occurs, and > + errno is set to EDOM in MATH_ERRNO mode; > + the invalid exception is raised in MATH_ERREXCEPT mode. > [to align with C99 Annex F.4] > > + If x is too large to be represented as a long, a *range* error > may occur, and > + errno *may be* set to ERANGE in MATH_ERRNO mode; > [to align with C99 7.12.9.7] > + the invalid exception *is* raised in MATH_ERREXCEPT mode. > [to align with C99 Annex F.4] > > They believe it is a bit awkward to have errno set to ERANGE in > MATH_ERRNO mode yet the invalid exception raised in MAH_ERREXCEPT mode, > but that just reflects an imperfect mapping of the C notion of errno to > the IEEE 754 notion of data conversion. > > I'll work with our expert to draft text refecting the above to suggest > replacement text for lines 23678-23684 on lround page 721 of XSH6. > > Thanks > > Joanna > > > Andrew Josey wrote: > > > > The text referred to is MX shaded and part of the ISO 60559 floating > > point option. I do not think changing the Domain Error to a Range Error > > is the fix or at least not the fix for the NaN and +-Inf cases. ISO C > > 99 describes the range error case if the magnitude of x is too large as a > > may fail. I'll ask Fred T for his thoughts on this one... > > regards > > Andrew > > > > On Nov 12, 9:37am in "Defect in XBD lround", Erwin.Unruh@fujitsu-siemens.com wrote: > > > Defect report from : Erwin Unruh , Fujitsu Siemens Computers > > > > > > (Please direct followup comments direct to austin-group-l@opengroup.org) > > > > > > @ page 0 line 0 section lround objection {0} > > > > > > Problem: > > > > > > Defect code : 1. Error > > > > > > The function lround is described in http://www.opengroup.org/onlinepubs/007904975/functions/lround.html > > > On Error it is specified that errno has to be set to EDOM. However, the C99 standard ISO/IEC 9899:1999 (E) specifies this as a range error, which would result in a value of ERANGE. So an implementation could not be conformant to both these standards. > > > > > > Action: > > > > > > Change the value of errno to ERANGE, if the result is not represantable. More specific: In the description of the function, replace all occurences of "domain error" with "range error" and replace "EDOM" with "ERANGE" > > >-- End of excerpt from Erwin.Unruh@fujitsu-siemens.com > > ----- Andrew Josey The Open Group Austin Group Chair Apex Plaza,Forbury Road, Email: a.josey@opengroup.org Reading,Berks.RG1 1AX,England Tel: +44 118 9508311 ext 2250 Fax: +44 118 9500110 Email-Simple-2.201/t/test-mails/josey-nobody000644 000766 000766 00000001367 11111624535 020651 0ustar00rjbsrjbs000000 000000 Received: (qmail 1679 invoked by uid 503); 13 Nov 2002 10:10:49 -0000 Resent-Date: 13 Nov 2002 10:10:49 -0000 Date: Wed, 13 Nov 2002 10:06:51 GMT From: Andrew Josey Message-Id: <1021113100650.ZM12997@skye.rdg.opengroup.org> In-Reply-To: Joanna Farley's message as of Nov 13, 9:56am. X-Mailer: Z-Mail (5.0.0 30July97) To: austin-group-l@opengroup.org Subject: Re: Defect in XBD lround MIME-Version: 1.0 Resent-Message-ID: Resent-To: austin-group-l@opengroup.org Resent-From: austin-group-l@opengroup.org X-Mailing-List: austin-group-l:archive/latest/4823 X-Loop: austin-group-l@opengroup.org Precedence: list Resent-Sender: austin-group-l-request@opengroup.org Content-Type: text/plain; charset=us-ascii Email-Simple-2.201/t/test-mails/josey-nobody-blank000644 000766 000766 00000001370 11111624535 021730 0ustar00rjbsrjbs000000 000000 Received: (qmail 1679 invoked by uid 503); 13 Nov 2002 10:10:49 -0000 Resent-Date: 13 Nov 2002 10:10:49 -0000 Date: Wed, 13 Nov 2002 10:06:51 GMT From: Andrew Josey Message-Id: <1021113100650.ZM12997@skye.rdg.opengroup.org> In-Reply-To: Joanna Farley's message as of Nov 13, 9:56am. X-Mailer: Z-Mail (5.0.0 30July97) To: austin-group-l@opengroup.org Subject: Re: Defect in XBD lround MIME-Version: 1.0 Resent-Message-ID: Resent-To: austin-group-l@opengroup.org Resent-From: austin-group-l@opengroup.org X-Mailing-List: austin-group-l:archive/latest/4823 X-Loop: austin-group-l@opengroup.org Precedence: list Resent-Sender: austin-group-l-request@opengroup.org Content-Type: text/plain; charset=us-ascii Email-Simple-2.201/t/test-mails/josey-nofold000644 000766 000766 00000007770 11111624535 020644 0ustar00rjbsrjbs000000 000000 Received: (qmail 1679 invoked by uid 503); 13 Nov 2002 10:10:49 -0000 Resent-Date: 13 Nov 2002 10:10:49 -0000 Date: Wed, 13 Nov 2002 10:06:51 GMT From: Andrew Josey Message-Id: <1021113100650.ZM12997@skye.rdg.opengroup.org> In-Reply-To: Joanna Farley's message as of Nov 13, 9:56am. X-Mailer: Z-Mail (5.0.0 30July97) To: austin-group-l@opengroup.org Subject: Re: Defect in XBD lround MIME-Version: 1.0 Resent-Message-ID: Resent-To: austin-group-l@opengroup.org Resent-From: austin-group-l@opengroup.org X-Mailing-List: austin-group-l:archive/latest/4823 X-Loop: austin-group-l@opengroup.org Precedence: list Resent-Sender: austin-group-l-request@opengroup.org Content-Type: text/plain; charset=us-ascii Joanna, All Thanks. I got the following response from Fred Tydeman. C99 Defect Report (DR) 240 covers this. The main body of C99 (7.12.9.7) says range error, while Annex F (F.9.6.7 and F.9.6.5) says "invalid" (domain error). The result was to change 7.12.9.7 to allow for either range or domain error. The preferred error is domain error (so as match Annex F). So, no need to change XBD. regards Andrew On Nov 13, 9:56am in "Re: Defect in XBD lr", Joanna Farley wrote: > Sun's expert in this area after some discussions with a colleague > outside of Sun concluded that for lround, to align with both C99 and SUS > changes of the following form were necessary: > > + If x is +/-Inf/NaN, a domain error occurs, and > + errno is set to EDOM in MATH_ERRNO mode; > + the invalid exception is raised in MATH_ERREXCEPT mode. > [to align with C99 Annex F.4] > > + If x is too large to be represented as a long, a *range* error > may occur, and > + errno *may be* set to ERANGE in MATH_ERRNO mode; > [to align with C99 7.12.9.7] > + the invalid exception *is* raised in MATH_ERREXCEPT mode. > [to align with C99 Annex F.4] > > They believe it is a bit awkward to have errno set to ERANGE in > MATH_ERRNO mode yet the invalid exception raised in MAH_ERREXCEPT mode, > but that just reflects an imperfect mapping of the C notion of errno to > the IEEE 754 notion of data conversion. > > I'll work with our expert to draft text refecting the above to suggest > replacement text for lines 23678-23684 on lround page 721 of XSH6. > > Thanks > > Joanna > > > Andrew Josey wrote: > > > > The text referred to is MX shaded and part of the ISO 60559 floating > > point option. I do not think changing the Domain Error to a Range Error > > is the fix or at least not the fix for the NaN and +-Inf cases. ISO C > > 99 describes the range error case if the magnitude of x is too large as a > > may fail. I'll ask Fred T for his thoughts on this one... > > regards > > Andrew > > > > On Nov 12, 9:37am in "Defect in XBD lround", Erwin.Unruh@fujitsu-siemens.com wrote: > > > Defect report from : Erwin Unruh , Fujitsu Siemens Computers > > > > > > (Please direct followup comments direct to austin-group-l@opengroup.org) > > > > > > @ page 0 line 0 section lround objection {0} > > > > > > Problem: > > > > > > Defect code : 1. Error > > > > > > The function lround is described in http://www.opengroup.org/onlinepubs/007904975/functions/lround.html > > > On Error it is specified that errno has to be set to EDOM. However, the C99 standard ISO/IEC 9899:1999 (E) specifies this as a range error, which would result in a value of ERANGE. So an implementation could not be conformant to both these standards. > > > > > > Action: > > > > > > Change the value of errno to ERANGE, if the result is not represantable. More specific: In the description of the function, replace all occurences of "domain error" with "range error" and replace "EDOM" with "ERANGE" > > >-- End of excerpt from Erwin.Unruh@fujitsu-siemens.com > > ----- Andrew Josey The Open Group Austin Group Chair Apex Plaza,Forbury Road, Email: a.josey@opengroup.org Reading,Berks.RG1 1AX,England Tel: +44 118 9508311 ext 2250 Fax: +44 118 9500110 Email-Simple-2.201/t/test-mails/junk-in-header000644 000766 000766 00000000133 11111624535 021017 0ustar00rjbsrjbs000000 000000 linden boulevard represent, represent Header-One: steve biko Header-Two: stir it up ATCQ! Email-Simple-2.201/t/test-mails/long-msgid000644 000766 000766 00000022472 11111624535 020270 0ustar00rjbsrjbs000000 000000 Received: from ls2.sba.com ([206.69.91.6]:22703 helo=ls.sba.com) by smtp.paravolve.net with smtp (Exim 4.34) id 1BTp3v-0007sJ-Pj for jwb@paravolve.net; Fri, 28 May 2004 21:38:49 +0000 From: Encompass To: jwb@paravolve.net Subject: Encompass Points - May 2004 Date: Fri, 28 May 2004 16:02:19 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit List-Unsubscribe: Message-Id: X-ParaVolve-Scan-Signature: 85328c83c550adce6a970aeb2e21d0bc X-ParaVolve-Spam-Score: 0.0, (/) _Encompass Points_ Issue 17, May 2004 Thank you for subscribing to the newsletter _Encompass Points_! To view this publication online, go to http://www.encompassUS.org/news/points/index.html. Encompass Points is a monthly e-mail newsletter for Encompass, an independent, volunteer-driven organization providing HP users with opportunities for education, peer networking and vendor advocacy. Issue Contents: * HP World 2004 Heats Up With Hot Topics For the HP IT Community * Encompass 2004 Board of Directors Election * Webcasts Sponsored by Encompass and MindIQ Another Success * Sign Up For the Next Encompass and MindIQ Webcast * Sign Up for HP's Webcast * Encompass Local User Group News * Encompass Special Interest Groups * HP Customer News - Ready For You * Events Calendar * We Want Your Feedback and Submissions HP WORLD 2004 HEATS UP WITH HOT TOPICS FOR THE HP IT COMMUNITY HP World 2004 promises to offer a wide-ranging technical program covering today's hottest topics for HP customers and users. For the second consecutive year, the Encompass and Interex user communities have joined forces to bring you an opportunity-rich agenda of education, new product information, and peer networking. Join more than 7,000 of your colleagues from the HP IT community at this, the largest HP-focused technology conference in the Americas! Registration is now open with an "early bird" savings of $100 for registrations received by July 23. Encompass members qualify for an additional savings of $200. Find out more at http://www.hpworld.com/. Along with the 400+ technical sessions offered, the following is a sample of some of the technical information you'll find at HP World 2004: - Adaptive Enterprise - Find out more about HP's Adaptive Enterprise vision and how to apply various technologies toward making your enterprise more adaptive. - Storage - Benefit from an introduction to storage area networks. - HP-UX - Listen to a panel on HP-UX performance and a discussion of future directions. - Tru64 - Find out about HP's road map for integrating Tru64 functionality into HP-UX. - OpenVMS - Hear from a panel of engineering experts and get a technical update. - Linux - Hear actual case studies and gather "how-tos" for building Linux distribution. - Itanium - Learn about real-world experiences porting to Itanium, and take a look at HP's future Itanium plans. - Security - Witness a live hacking demo and learn how the super spies compromise security. - High Availability and Disaster Recovery - Hear a discussion of trends and best practices. - IA32 - Learn about ProLiant Clusters and how to put blade servers to effective use. - Networking - Get practical advice about troubleshooting and anti-spam solutions. - Windows - Learn about Windows 2003 and see a cost comparison of Windows and Linux. - MPE - Arm yourself with strategies for migrating from HP e3000-based applications to other platforms. For complete program details, visit http://www.hpworld.com/. Be sure to check back often for updates. And watch your e-mail inbox for more about the information-rich programs, training seminars, and workshops that will be offered at HP World 2004. ENCOMPASS 2004 BOARD OF DIRECTORS ELECTION The deadline for the Encompass Board of Directors Election Call for Candidates is fast approaching! All individual and corporate members in good standing are eligible to run for the Encompass Board of Directors. If you are interested in being a part of the leadership of Encompass, please go to http://www.encompassUS.org/elections.html and submit your application for candidacy by June 4, 2004 to mailto:elections@encompassUS.org. WEBCAST SPONSORED BY ENCOMPASS AND MINDIQ ANOTHER SUCCESS On April 15, Peter Sward from HP presented on the transition from Tru64 UNIX to HP-UX in the free Encompass and MindIQ webcast. The free webcast focused on the tools that HP is developing to assist customers with the transition of their home-grown applications from Tru64 UNIX to HP-UX on Itanium-based systems. SIGN UP FOR THE NEXT ENCOMPASS AND MIND IQ WEBCAST On June 10, James Percent, Software Engineer in the Enterprise UNIX Division at HP, will present "Selecting the Most Appropriate Cluster Interconnect Technology for a TruCluster Deployment". The free webcast will provide practical information regarding the impacts of the cluster interconnect upon overall application availability, scalability, and performance in a TruCluster Server environment. To register for this webcast offering, visit http://www.encompassUS.org/events/webcasts.html. SIGN UP FOR HP'S WEBCAST Sign-up for the June 15th HP webcast entitled "Using Intel Compilers to Best Extract Performance from Itanium 2-based Platforms Webcast." The webcast will cover the benefits of using threading tools to improve your development efforts. Shine a brilliant spotlight on the unseen internal behavior of your multithreaded application with the debugging and analysis tools. Easily navigate the threads and synchronization objects in your application with complete correlation back to the source code. After attending this event you should understand the capabilities of the Visual Threads debugging and analysis tool, and be able to easily apply it to your multithreaded application. You will be able to improve the robustness of your application, identify potential performance bottlenecks, and explore the previously unseen behavior of your application as it executes. For more information and to register go to: http://h21007.www2.hp.com/dspp/ne/ne_EventDetail_IDX/1,1394,723,00.html ENCOMPASS LOCAL USER GROUP NEWS "ESILUG, an Encompass Local User Group in the Washington, DC area will meet on Tuesday, June 1, from 1-4pm. We'll be taking a practical look at the tools that aid Windows server consolidation. Dennis Bonanni of HP will share his experiences and knowledge of ways to consolidate Windows servers effectively. Pete Nash of Microsoft will describe the Microsoft Virtual Server product. To register and to find out more, see http://encompasserve.org/lugs/esilug/." Local User Groups (LUGs) are a key part of the Encompass community. There are many Encompass LUGs which offer members an opportunity to interact with fellow IT professionals face-to-face, close to home. These LUGS host local meetings and events that allow customers to stay connected with HP developments. Become involved with a user group in your area to interact directly with others in a friendly, familiar forum. To find a LUG in your area visit http://www.encompassUS.org/community/LUGS/ ENCOMPASS SPECIAL INTEREST GROUPS (SIGS) Take advantage of the direct customer contact Encompass Special Interest Groups (SIGs) offer you. SIGs are recognized forums where HP users, with a vested interest in enterprise computing, exchange ideas and discuss technologies. Organized by Encompass members, SIG members meet annually at the annual conference and interact weekly via mailing lists. You are invited to join one of the four SIGS: Linux SIG, Enterprise Unix, OpenVMS, and Enterprise Storage at http://www.encompassUS.org/community/sigs/sigjoin.html. HP CUSTOMER NEWS - READY FOR YOU Have you read HP's 'Customer Times'? [http://www.hp.com/products1/evolution/customertimes/index.html] It's a storage and server newsletter brimming with stories of interest for HP's worldwide customers. It's available now in two easy versions: online (html) and print-ready (pdf). 'Customer Times' provides you with news updates from across the whole spectrum of HP offerings, including OpenVMS, Tru64 UNIX, HP-UX, Linux and more. It's simple to become a quarterly subscriber, too. Register now at http://www.hp.com/products1/evolution/customertimes/customertimes_reg.html! EVENTS CALENDAR Encompass and HP community events are promoted via an online events calendar at http://www.encompassUS.org/calendar/index.cfm Check this calendar on a regular basis to learn about upcoming Encompass events. Forward calendar posting requests to information@encompassUS.org. WE WANT YOUR FEEDBACK AND SUBMISSIONS Is there something you'd like to see in Encompass Points? Let us know. If you have news, updates or something special you'd like to let the Encompass community know, please send to information@encompassUS.org. * * * Interested in advertising? E-mail information@encompassUS.org. Previous issues of Encompass Points are available in the online archives. Access them at http://www.encompassUS.org/members/points_archive/. * * * How to Avoid Missing our Newsletter: Your newsletter will be coming from this address: {information@encompassUS.org} Add this to your list of addresses from which you want to receive mail. Encompass Headquarters 401 N. Michigan Avenue Suite 2200 Chicago, IL 60611 Tel: 877.354.9887 Email-Simple-2.201/t/test-mails/many-repeats000644 000766 000766 00000000445 11111624535 020631 0ustar00rjbsrjbs000000 000000 Baz: 0 Foo: 1 Bar: 2 Foo: 3 Bar: 4 Foo: 5 Bar: 6 Foo: 7 Bar: 8 Foo: 9 Bar: A Foo: B Bar: C Foo: D Bar: E Foo: F Bar: G Foo: H Bar: I Foo: J Bar: K Foo: L Bar: M Foo: N Bar: O Foo: P Bar: Q Foo: R Bar: S Foo: T Bar: U Foo: V Bar: W Foo: X Foo: Y Bar: Z Baz: 0 This is a really stupid message. Email-Simple-2.201/lib/Email/000755 000766 000766 00000000000 12133267623 015554 5ustar00rjbsrjbs000000 000000 Email-Simple-2.201/lib/Email/Simple/000755 000766 000766 00000000000 12133267623 017005 5ustar00rjbsrjbs000000 000000 Email-Simple-2.201/lib/Email/Simple.pm000644 000766 000766 00000021316 12133267056 017346 0ustar00rjbsrjbs000000 000000 use 5.006; use strict; use warnings; package Email::Simple; use Carp (); use Email::Simple::Creator; use Email::Simple::Header; our $VERSION = '2.201'; $VERSION = eval $VERSION; our $GROUCHY = 0; # We are liberal in what we accept. sub __crlf_re { qr/\x0a\x0d|\x0d\x0a|\x0a|\x0d/; } =head1 NAME Email::Simple - simple parsing of RFC2822 message format and headers =head1 SYNOPSIS use Email::Simple; my $email = Email::Simple->new($text); my $from_header = $email->header("From"); my @received = $email->header("Received"); $email->header_set("From", 'Simon Cozens '); my $old_body = $email->body; $email->body_set("Hello world\nSimon"); print $email->as_string; ...or, to create a message from scratch... my $email = Email::Simple->create( header => [ From => 'casey@geeknest.com', To => 'drain@example.com', Subject => 'Message in a bottle', ], body => '...', ); $email->header_set( 'X-Content-Container' => 'bottle/glass' ); print $email->as_string; =head1 DESCRIPTION C is 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. C modules are meant to be simple to use and to maintain, pared to the bone, fast, minimal in their external dependencies, and correct. =head1 METHODS =head2 new my $email = Email::Simple->new($message, \%arg); This method parses an email from a scalar containing an RFC2822 formatted message and returns an object. C<$message> may 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 C> method. Valid arguments are: header_class - the class used to create new header objects The named module is not 'require'-ed by Email::Simple! =cut sub new { my ($class, $text, $arg) = @_; $arg ||= {}; Carp::croak 'Unable to parse undefined message' if ! defined $text; my $text_ref = ref $text ? $text : \$text; my ($pos, $mycrlf) = $class->_split_head_from_body($text_ref); my $self = bless { mycrlf => $mycrlf } => $class; my $head; if (defined $pos) { $head = substr $$text_ref, 0, $pos, ''; substr($head, -(length $mycrlf)) = ''; } else { $head = $$text_ref; $text_ref = \''; } my $header_class = $arg->{header_class} || $self->default_header_class; $self->header_obj_set( $header_class->new(\$head, { crlf => $self->crlf }) ); $self->body_set($text_ref); return $self; } # Given the text of an email, return ($pos, $crlf) where $pos is the position # at which the body text begins and $crlf is the type of newline used in the # message. sub _split_head_from_body { my ($self, $text_ref) = @_; # For body/header division, see RFC 2822, section 2.1 my $crlf = $self->__crlf_re; if ($$text_ref =~ /(?:.*?($crlf))\1/gsm) { return (pos($$text_ref), $1); } else { # The body is, of course, optional. $$text_ref =~ /($crlf)/gsm; return (undef, ($1 || "\n")); } } =head2 create my $email = Email::Simple->create(header => [ @headers ], body => '...'); This method is a constructor that creates an Email::Simple object from a set of named parameters. The C
parameter's value is a list reference containing a set of headers to be created. The C parameter's value is a scalar value holding the contents of the message body. Line endings in the body will normalized to CRLF. If no C header is specified, one will be provided for you based on the C of the local machine. This is because the C field is a required header and is a pain in the neck to create manually for every message. The C field is also a required header, but it is I provided for you. =cut our $CREATOR = 'Email::Simple::Creator'; sub create { my ($class, %args) = @_; # We default it in here as well as below because by having it here, then we # know that if there are no other headers, we'll get the proper CRLF. # Otherwise, we get a message with incorrect CRLF. -- rjbs, 2007-07-13 my $headers = $args{header} || [ Date => $CREATOR->_date_header ]; my $body = $args{body} || ''; my $empty = q{}; my $header = \$empty; for my $idx (map { $_ * 2 } 0 .. @$headers / 2 - 1) { my ($key, $value) = @$headers[ $idx, $idx + 1 ]; $CREATOR->_add_to_header($header, $key, $value); } $CREATOR->_finalize_header($header); my $email = $class->new($header); $email->header_set(Date => $CREATOR->_date_header) unless defined $email->header('Date'); $body = (join $CREATOR->_crlf, split /\x0d\x0a|\x0a\x0d|\x0a|\x0d/, $body) . $CREATOR->_crlf; $email->body_set($body); return $email; } =head2 header_obj my $header = $email->header_obj; This method returns the object representing the email's header. For the interface for this object, see L. =cut sub header_obj { my ($self) = @_; return $self->{header}; } # Probably needs to exist in perpetuity for modules released during the "__head # is tentative" phase, until we have a way to force modules below us on the # dependency tree to upgrade. i.e., never and/or in Perl 6 -- rjbs, 2006-11-28 BEGIN { *__head = \&header_obj } =head2 header_obj_set $email->header_obj_set($new_header_obj); This method substitutes the given new header object for the email's existing header object. =cut sub header_obj_set { my ($self, $obj) = @_; $self->{header} = $obj; } =head2 header 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 I value for the named header. =head2 header_set $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. If no values are given to set, the header will be removed from to the message entirely. =head2 header_names 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 C
method 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 B. =head2 header_pairs 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. =cut BEGIN { no strict 'refs'; for my $method (qw(header header_set header_names header_pairs)) { *$method = sub { (shift)->header_obj->$method(@_) }; } *headers = \&header_names; } =head2 body Returns the body text of the mail. =cut sub body { my ($self) = @_; return (defined ${ $self->{body} }) ? ${ $self->{body} } : ''; } =head2 body_set Sets the body text of the mail. =cut sub body_set { my ($self, $text) = @_; my $text_ref = ref $text ? $text : \$text; $self->{body} = $text_ref; return; } =head2 as_string Returns the mail as a string, reconstructing the headers. =cut sub as_string { my $self = shift; return $self->header_obj->as_string . $self->crlf . $self->body; } =head2 crlf This method returns the type of newline used in the email. It is an accessor only. =cut sub crlf { $_[0]->{mycrlf} } =head2 default_header_class This returns the class used, by default, for header objects, and is provided for subclassing. The default default is Email::Simple::Header. =cut sub default_header_class { 'Email::Simple::Header' } 1; __END__ =head1 CAVEATS 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 L anyway). For more information on this issue please consult RT issue 2478, L. =head1 PERL EMAIL PROJECT This module is maintained by the Perl Email Project L =head1 AUTHORS Simon Cozens originally wrote Email::Simple in 2003. Casey West took over maintenance in 2004, and Ricardo SIGNES took over maintenance in 2006. =head1 COPYRIGHT AND LICENSE 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. =cut Email-Simple-2.201/lib/Email/Simple/Creator.pm000644 000766 000766 00000001724 12133267067 020750 0ustar00rjbsrjbs000000 000000 use strict; use warnings; package Email::Simple::Creator; our $VERSION = '2.201'; $VERSION = eval $VERSION; sub _crlf { "\x0d\x0a"; } sub _date_header { require Email::Date::Format; Email::Date::Format::email_date(); } sub _add_to_header { my ($class, $header, $key, $value) = @_; $value = '' unless defined $value; $$header .= "$key: $value" . $class->_crlf; } sub _finalize_header { my ($class, $header) = @_; $$header .= $class->_crlf; } 1; __END__ =head1 NAME Email::Simple::Creator - private helper for building Email::Simple objects =head1 PERL EMAIL PROJECT This module is maintained by the Perl Email Project L =head1 AUTHORS Casey West originally wrote Email::Simple::Creator in 2004. Ricardo SIGNES took over maintenance in 2006. =head1 COPYRIGHT AND LICENSE Copyright (c) 2004 Casey West. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Email-Simple-2.201/lib/Email/Simple/Header.pm000644 000766 000766 00000020216 12133267073 020533 0ustar00rjbsrjbs000000 000000 package Email::Simple::Header; use strict; use Carp (); require Email::Simple; our $VERSION = '2.201'; $VERSION = eval $VERSION; =head1 NAME Email::Simple::Header - the header of an Email::Simple message =head1 SYNOPSIS my $email = Email::Simple->new($text); my $header = $email->head; print $header->as_string; =head1 DESCRIPTION This method implements the headers of an Email::Simple object. It is a very minimal interface, and is mostly for private consumption at the moment. =head1 METHODS =head2 new my $header = Email::Simple::Header->new($head, \%arg); C<$head> is a string containing a valid email header, or a reference to such a string. If a reference is passed in, don't expect that it won't be altered. Valid arguments are: crlf - the header's newline; defaults to CRLF =cut # We need to be able to: # * get all values by lc name # * produce all pairs, with case intact sub new { my ($class, $head, $arg) = @_; my $head_ref = ref $head ? $head : \$head; my $self = { mycrlf => $arg->{crlf} || "\x0d\x0a", }; my $headers = $class->_header_to_list($head_ref, $self->{mycrlf}); # for my $header (@$headers) { # push @{ $self->{order} }, $header->[0]; # push @{ $self->{head}{ $header->[0] } }, $header->[1]; # } # # $self->{header_names} = { map { lc $_ => $_ } keys %{ $self->{head} } }; $self->{headers} = $headers; bless $self => $class; } sub _header_to_list { my ($self, $head, $mycrlf) = @_; my @headers; my $crlf = Email::Simple->__crlf_re; while ($$head =~ m/\G(.+?)$crlf/go) { local $_ = $1; if (/^\s+/ or not /^([^:]+):\s*(.*)/) { # This is a continuation line. We fold it onto the end of # the previous header. next if !@headers; # Well, that sucks. We're continuing nothing? (my $trimmed = $_) =~ s/^\s+//; $headers[-1][0] .= $headers[-1][0] =~ /\S/ ? " $trimmed" : $trimmed; $headers[-1][1] .= "$mycrlf$_"; } else { push @headers, $1, [ $2, $_ ]; } } return \@headers; } =head2 as_string my $string = $header->as_string(\%arg); This returns a stringified version of the header. =cut # RFC 2822, 3.6: # ...for the purposes of this standard, header fields SHOULD NOT be reordered # when a message is transported or transformed. More importantly, the trace # header fields and resent header fields MUST NOT be reordered, and SHOULD be # kept in blocks prepended to the message. sub as_string { my ($self, $arg) = @_; $arg ||= {}; my $header_str = ''; my $headers = $self->{headers}; my $fold_arg = { # at => (exists $arg->{fold_at} ? $arg->{fold_at} : $self->default_fold_at), # indent => (exists $arg->{fold_indent} ? $arg->{fold_indent} : $self->default_fold_indent), at => $self->_default_fold_at, indent => $self->_default_fold_indent, }; for (my $i = 0; $i < @$headers; $i += 2) { if (ref $headers->[ $i + 1 ]) { $header_str .= $headers->[ $i + 1 ][1] . $self->crlf; } else { my $header = "$headers->[$i]: $headers->[$i + 1]"; $header_str .= $self->_fold($header, $fold_arg); } } return $header_str; } =head2 header_names This method returns the unique header names found in this header, in no particular order. =cut sub header_names { my $headers = $_[0]->{headers}; my %seen; grep { !$seen{ lc $_ }++ } map { $headers->[ $_ * 2 ] } 0 .. int($#$headers / 2); } =head2 header_pairs This method returns all the field/value pairs in the header, in the order that they appear in the header. =cut sub header_pairs { my ($self) = @_; my @pairs = map {; _str_value($_) } @{ $self->{headers} }; return @pairs; } =head2 header my $first_value = $header->header($field); my @all_values = $header->header($field); This method returns the value or values of the given header field. If the named field does not appear in the header, this method returns false. =cut sub _str_value { return ref $_[0] ? $_[0][0] : $_[0] } sub header { my ($self, $field) = @_; my $headers = $self->{headers}; my $lc_field = lc $field; if (wantarray) { return map { _str_value($headers->[ $_ * 2 + 1 ]) } grep { lc $headers->[ $_ * 2 ] eq $lc_field } 0 .. int($#$headers / 2); } else { for (0 .. int($#$headers / 2)) { return _str_value($headers->[ $_ * 2 + 1 ]) if lc $headers->[ $_ * 2 ] eq $lc_field; } return; } } =head2 header_set $header->header_set($field => @values); This method updates the value of the given header. Existing headers have their values set in place. Additional headers are added at the end. If no values are given to set, the header will be removed from to the message entirely. =cut # Header fields are lines composed of a field name, followed by a colon (":"), # followed by a field body, and terminated by CRLF. A field name MUST be # composed of printable US-ASCII characters (i.e., characters that have values # between 33 and 126, inclusive), except colon. A field body may be composed # of any US-ASCII characters, except for CR and LF. # However, a field body may contain CRLF when used in header "folding" and # "unfolding" as described in section 2.2.3. sub header_set { my ($self, $field, @data) = @_; # I hate this block. -- rjbs, 2006-10-06 if ($Email::Simple::GROUCHY) { Carp::croak "field name contains illegal characters" unless $field =~ /^[\x21-\x39\x3b-\x7e]+$/; Carp::carp "field name is not limited to hyphens and alphanumerics" unless $field =~ /^[\w-]+$/; } my $headers = $self->{headers}; my $lc_field = lc $field; my @indices = grep { lc $headers->[$_] eq $lc_field } map { $_ * 2 } 0 .. int($#$headers / 2); if (@indices > @data) { my $overage = @indices - @data; splice @{$headers}, $_, 2 for reverse @indices[ -$overage .. -1 ]; pop @indices for (1 .. $overage); } elsif (@data > @indices) { my $underage = @data - @indices; for (1 .. $underage) { push @$headers, $field, undef; # temporary value push @indices, $#$headers - 1; } } for (0 .. $#indices) { $headers->[ $indices[$_] + 1 ] = $data[$_]; } return wantarray ? @data : $data[0]; } =head2 crlf This method returns the newline string used in the header. =cut sub crlf { $_[0]->{mycrlf} } # =head2 fold # # my $folded = $header->fold($line, \%arg); # # Given a header string, this method returns a folded version, if the string is # long enough to warrant folding. This method is used internally. # # Valid arguments are: # # at - fold lines to be no longer than this length, if possible # if given and false, never fold headers # indent - indent lines with this string # # =cut sub _fold { my ($self, $line, $arg) = @_; $arg ||= {}; $arg->{at} = $self->_default_fold_at unless exists $arg->{at}; return $line . $self->crlf unless $arg->{at} and $arg->{at} > 0; my $limit = ($arg->{at} || $self->_default_fold_at) - 1; return $line . $self->crlf if length $line <= $limit; $arg->{indent} = $self->_default_fold_indent unless exists $arg->{indent}; my $indent = $arg->{indent} || $self->_default_fold_indent; # We know it will not contain any new lines at present my $folded = ""; while ($line) { if ($line =~ s/^(.{0,$limit})(\s|\z)//) { $folded .= $1 . $self->crlf; $folded .= $indent if $line; } else { # Basically nothing we can do. :( $folded .= $line . $self->crlf; last; } } return $folded; } # =head2 default_fold_at # # This method (provided for subclassing) returns the default length at which to # try to fold header lines. The default default is 78. # # =cut sub _default_fold_at { 78 } # =head2 default_fold_indent # # This method (provided for subclassing) returns the default string used to # indent folded headers. The default default is a single space. # # =cut sub _default_fold_indent { " " } =head1 PERL EMAIL PROJECT This module is maintained by the Perl Email Project L =head1 COPYRIGHT AND LICENSE Copyright 2006-2007 by Ricardo SIGNES 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. =cut 1;