Skip to content
Browse files

3.01_04

  • Loading branch information...
1 parent d35dbed commit efab19d4f2af220107843bf2f6ac4d903d2d6472 @rjbs committed
Showing with 6,115 additions and 5,993 deletions.
  1. +41 −41 COPYING
  2. +26 −26 INSTALLING
  3. +26 −26 MANIFEST
  4. +48 −20 Makefile.PL
  5. +97 −97 README
  6. +433 −429 changes.pod
  7. +322 −322 contrib/MailTool.pm
  8. +4 −4 contrib/README
  9. +69 −69 examples/mime_fwd
  10. +93 −93 examples/mime_gif
  11. +58 −58 examples/mime_hack
  12. +92 −92 examples/mime_longlines
  13. +79 −79 examples/mime_postcard
  14. +21 −21 examples/nodisp
  15. +3,687 −3,597 lib/MIME/Lite.pm
  16. +612 −612 t/ExtUtils/TBone.pm
  17. +23 −23 t/Utils.pm
  18. +87 −87 t/addrs.t
  19. +55 −55 t/data.t
  20. +87 −87 t/head.t
  21. +37 −37 t/parts.t
  22. +76 −76 t/types.t
  23. +39 −39 t/verify.t
  24. +1 −1 testin/README
  25. +2 −2 testin/hello
View
82 COPYING
@@ -1,41 +1,41 @@
-The "MIME-Lite" Perl5 toolkit.
-
-Copyright (c) 1996 by Eryq. All rights reserved.
-Copyright (c) 1999 by ZeeGee Software Inc. All rights reserved.
-
-This program is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself.
-
-You should have received a copy of the Perl license along with
-Perl; see the file README in Perl distribution.
-
-You should have received a copy of the GNU General Public License
-along with Perl; see the file Copying. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-You should have received a copy of the Artistic License
-along with Perl; see the file Artistic.
-
- NO WARRANTY
-
-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.
-
-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 "MIME-Lite" Perl5 toolkit.
+
+Copyright (c) 1996 by Eryq. All rights reserved.
+Copyright (c) 1999 by ZeeGee Software Inc. All rights reserved.
+
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+You should have received a copy of the Perl license along with
+Perl; see the file README in Perl distribution.
+
+You should have received a copy of the GNU General Public License
+along with Perl; see the file Copying. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+You should have received a copy of the Artistic License
+along with Perl; see the file Artistic.
+
+ NO WARRANTY
+
+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.
+
+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
View
52 INSTALLING
@@ -1,26 +1,26 @@
-------------------------------------------------------------
-STANDARD INSTALLATION
-
-On most systems, just do this from the command line:
-
- perl Makefile.PL
- make test
- make install
-
-Please note that you'll need permission to write to the
-standard installation directories; under Unix-like systems, this
-often means that you must be logged in as "root".
-
-If you're on a non-Unix platform, you might be using 'dmake'
-instead of 'make'.
-
-------------------------------------------------------------
-NON-STANDARD INSTALLATION
-
-To install to a non-standard place else (e.g., "/home/me/lib"),
-see the manual page for ExtUtils::MakeMaker, or try this:
-
- perl Makefile.PL LIB=/home/me/lib
- make test
- make install
-
+------------------------------------------------------------
+STANDARD INSTALLATION
+
+On most systems, just do this from the command line:
+
+ perl Makefile.PL
+ make test
+ make install
+
+Please note that you'll need permission to write to the
+standard installation directories; under Unix-like systems, this
+often means that you must be logged in as "root".
+
+If you're on a non-Unix platform, you might be using 'dmake'
+instead of 'make'.
+
+------------------------------------------------------------
+NON-STANDARD INSTALLATION
+
+To install to a non-standard place else (e.g., "/home/me/lib"),
+see the manual page for ExtUtils::MakeMaker, or try this:
+
+ perl Makefile.PL LIB=/home/me/lib
+ make test
+ make install
+
View
52 MANIFEST
@@ -1,27 +1,27 @@
-COPYING
-INSTALLING
-MANIFEST
-Makefile.PL
-README
-contrib/MailTool.pm
-contrib/README
-examples/mime_fwd
-examples/mime_gif
-examples/mime_hack
-examples/mime_longlines
-examples/mime_postcard
-examples/nodisp
-lib/MIME/Lite.pm
-t/ExtUtils/TBone.pm
-t/Utils.pm
-t/addrs.t
-t/data.t
-t/head.t
-t/parts.t
-t/verify.t
-t/types.t
-testin/README
-testin/hello
-testin/test.html
-changes.pod
+COPYING
+INSTALLING
+MANIFEST
+Makefile.PL
+README
+contrib/MailTool.pm
+contrib/README
+examples/mime_fwd
+examples/mime_gif
+examples/mime_hack
+examples/mime_longlines
+examples/mime_postcard
+examples/nodisp
+lib/MIME/Lite.pm
+t/ExtUtils/TBone.pm
+t/Utils.pm
+t/addrs.t
+t/data.t
+t/head.t
+t/parts.t
+t/verify.t
+t/types.t
+testin/README
+testin/hello
+testin/test.html
+changes.pod
META.yml Module meta-data (added by MakeMaker)
View
68 Makefile.PL
@@ -1,20 +1,48 @@
-#!/usr/bin/perl
-use ExtUtils::MakeMaker;
-
-#------------------------------------------------------------
-# Makefile:
-#------------------------------------------------------------
-
-# Write the Makefile:
-WriteMakefile(
- NAME => 'MIME::Lite',
- VERSION_FROM => "lib/MIME/Lite.pm",
- DISTNAME => "MIME-Lite",
- EXE_FILES => [@EXES],
- 'dist' => {
- #PREOP => 'cvu_perl_preop -m MIME::Lite -f',#demerphq
- COMPRESS => 'gzip',
- SUFFIX => 'gz',
- }
- );
-
+#!/usr/bin/perl
+use ExtUtils::MakeMaker;
+
+#------------------------------------------------------------
+# Makefile:
+#------------------------------------------------------------
+
+print "MIME::Lite is designed to take advantage of a variety of external modules\n",
+ "if they are not present then MIME::Lite will attempt to do its best\n",
+ "but its strongly recommend that you install them.\n\n",
+ "These modules are:\n",
+ "\tMail::Address\n",
+ "\tMIME::Types\n",
+ "\tFile::Basename\n",
+ "\tMIME::Base64\n",
+ "\tMIME::QuotedPrint\n",
+ "Some or all of these maybe included with your perl, neverless if you wish\n",
+ "I can add these modules to the prereq list which will cause the files to be\n",
+ "automatically installed if they arent already present\n";
+my %prereq;
+if (prompt("Add prereqs?",'Yes')=~/y/i) {
+ %prereq=(
+ 'Mail::Address' => 1.62,
+ 'MIME::Types' => 1.13,
+ 'File::Basename' => undef,
+ 'MIME::Base64' => undef,
+ 'MIME::QuotedPrint' => undef,
+ );
+}
+
+
+
+
+
+# Write the Makefile:
+WriteMakefile(
+ NAME => 'MIME::Lite',
+ VERSION_FROM => "lib/MIME/Lite.pm",
+ DISTNAME => "MIME-Lite",
+ EXE_FILES => [@EXES],
+ 'dist' => {
+ #PREOP => 'cvu_perl_preop -m MIME::Lite -f',#demerphq
+ COMPRESS => 'gzip',
+ SUFFIX => 'gz',
+ },
+ 'PREREQ_PM' => \%prereq,
+ );
+
View
194 README
@@ -1,97 +1,97 @@
-This is MIME::Lite 3.01_01 Test Maintenance Release
--------------------------------------------------------------------------
-TEST RELEASE
- Please be WARNED that this is a test release and should NOT be blindly
- put into production. I would appreciate any and all feedback as to
- whether any problems occur in using it, especially as I have no way
- currently to test sendmail functionality.
-
-INSTALLATION
- Install using
-
- perl makefile.pl
- make test
- make install
-
- Or instead of the last line, even better is
-
- make install TEST_VERBOSE=1
-
- Adjust the make command as is appropriate for your OS. 'nmake' is the
- usual name under Win32
-
- In order to read the docmentation please use
-
- perldoc MIME::Lite
-
- from the command line or visit
-
- http://search.cpan.org/search?query=MIME%3A%3ALite&mode=all
-
- for a list of all MIME::Lite related materials including the
- documentation in HTML of all of the released versions of MIME::Lite.
-
-BUNDLED GOODIES
- MIME::Lite comes with a number of extra files in the distribution
- bundle. This includes examples, and utility modules that you can use to
- get yourself started with the module.
-
- The ./examples directory contains a number of snippets in prepared form,
- generally they are documented, but they should be easy to understand.
-
- The ./contrib directory contains a companion/tool modules that come
- bundled with MIME::Lite, they dont get installed by default. Please
- review the POD they come with.
-
-OTHER MODULES
- MIME::Lite works nicely with other certain other modules if they are present.
- Good to have installed is the latest MIME::Types, Mail::Address MIME::Base64.
-
-BUGS
- Should tests fail please review the ./testout directory, and in any bug
- reports please include the output of the relevent file. This is the only
- redeeming feature of not using Test::More that I can see.
-
- Bug fixes / Patches / Contribution are welcome, however I probably won't
- apply them unless they also have an associated test. This means that if
- I dont have the time to write the test the patch wont get applied, so
- please, include tests for any patches you provide.
-
-TERMS AND CONDITIONS
- Copyright (c) 1997 by Eryq.
- Copyright (c) 1998 by ZeeGee Software Inc.
- Copyright (c) 2003 Yves Orton. demerphq (at) hotmail.com.
-
- All rights reserved. This program is free software; you can
- redistribute it and/or modify it under the same terms as Perl
- itself.
-
- This software comes with NO WARRANTY of any kind. See the COPYING
- file in the distribution for details.
-
--------------------------------------------------------------------------------
-
-Visit perlmonks.org for a excellent community of perl programmers, experts and
-just generally nice and knowledgable people. Be sure to post a code snippet
-that illustrates your question if you go there for advice.
-
--------------------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+This is MIME::Lite 3.01_01 Test Maintenance Release
+-------------------------------------------------------------------------
+TEST RELEASE
+ Please be WARNED that this is a test release and should NOT be blindly
+ put into production. I would appreciate any and all feedback as to
+ whether any problems occur in using it, especially as I have no way
+ currently to test sendmail functionality.
+
+INSTALLATION
+ Install using
+
+ perl makefile.pl
+ make test
+ make install
+
+ Or instead of the last line, even better is
+
+ make install TEST_VERBOSE=1
+
+ Adjust the make command as is appropriate for your OS. 'nmake' is the
+ usual name under Win32
+
+ In order to read the docmentation please use
+
+ perldoc MIME::Lite
+
+ from the command line or visit
+
+ http://search.cpan.org/search?query=MIME%3A%3ALite&mode=all
+
+ for a list of all MIME::Lite related materials including the
+ documentation in HTML of all of the released versions of MIME::Lite.
+
+BUNDLED GOODIES
+ MIME::Lite comes with a number of extra files in the distribution
+ bundle. This includes examples, and utility modules that you can use to
+ get yourself started with the module.
+
+ The ./examples directory contains a number of snippets in prepared form,
+ generally they are documented, but they should be easy to understand.
+
+ The ./contrib directory contains a companion/tool modules that come
+ bundled with MIME::Lite, they dont get installed by default. Please
+ review the POD they come with.
+
+OTHER MODULES
+ MIME::Lite works nicely with other certain other modules if they are present.
+ Good to have installed is the latest MIME::Types, Mail::Address MIME::Base64.
+
+BUGS
+ Should tests fail please review the ./testout directory, and in any bug
+ reports please include the output of the relevent file. This is the only
+ redeeming feature of not using Test::More that I can see.
+
+ Bug fixes / Patches / Contribution are welcome, however I probably won't
+ apply them unless they also have an associated test. This means that if
+ I dont have the time to write the test the patch wont get applied, so
+ please, include tests for any patches you provide.
+
+TERMS AND CONDITIONS
+ Copyright (c) 1997 by Eryq.
+ Copyright (c) 1998 by ZeeGee Software Inc.
+ Copyright (c) 2003 Yves Orton. demerphq (at) hotmail.com.
+
+ All rights reserved. This program is free software; you can
+ redistribute it and/or modify it under the same terms as Perl
+ itself.
+
+ This software comes with NO WARRANTY of any kind. See the COPYING
+ file in the distribution for details.
+
+-------------------------------------------------------------------------------
+
+Visit perlmonks.org for a excellent community of perl programmers, experts and
+just generally nice and knowledgable people. Be sure to post a code snippet
+that illustrates your question if you go there for advice.
+
+-------------------------------------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
View
862 changes.pod
@@ -1,429 +1,433 @@
-=head1 CHANGE LOG
-
-=over 4
-
-=item Version 3.01_02 (2003/08/28)
-
-Well, it seems 3.01_01 failed tests on Win32 due to me accidentally changing the line ending
-format to DOSish. Also the way that email extraction for SMTP with or without Mail::Address
-was different (from 2.117 even). So ive fixed that.
-
-Anybody depending on the undocumented extract_addrs() is in for a suprise. I suggest you look
-at using Mail::Address.
-
-=item Version 3.01_01 (2003/04/25 - 2003/08/21)
-
-(This version is a test release, if its ok then I'll re-release it as 3.02)
-
-Patched the pod to use correct entities Thanks to Ed Avis for the patch.
-Added better support for funky names in the from field when sending via SMTP, thanks to
-prodding by Darren Hemphill and Ollie Gallardo. (Actually I kind of messed this up orginally
-and no doubt Darren wasn't impressed. I ended up using something pretty close to his solution.
-My bad for not paying more attention. Sorry mate.)
-
-08/21: Apparently I never uploaded my changes for this version to CPAN. Sigh.
-
-*** Win32 CHANGES ***
-
-Up until this release the default send() method for all OS'es has been to invoke sendmail
-and pipe the mail to it. This behaviour has now changed on Win32 to default to using SMTP.
-This means that if your /site/lib/Net/libnet.cfg file is properly configured then you can
-use SMTP without specifying a send method explicitly. This seemed a rational decision as
-most Win32 users who send mails are using an SMTP server and not a tool like sendmail.
-
-*** SMTP CHANGES ***
-
-Jonathan Eunice <jeunice at illuminata dot com> pointed out an interesting bug in the
-interaction between MIME::Lite and Net::SMTP/Net::CMD. This was that sending a mail
-ending in "\n\n" without additional encoding would cause Net::CMD to send an incorrect
-end of mail signal to the SMTP server which would result in A) The mail failing to be sent due
-to a timeout, and B) MIME::Lite to report that all was well.
-
-This has been fixed by checking to make sure that if the last character sent was \n, but the
-last two chars were not \r\n then the \n is turned into an \r, which Net::CMD then adds an \n
-to and then sends the normal ".\r\n" to terminate the message. Weird error, that im not
-entirely sure has been resolved properly. Please inform me if this screws anything up that it
-shouldn't.
-
-As stated earlier send_by_smtp wasnt extracting the _real_ email address from the overall fancy
-once specified in the From: field. This is resolved now, fancy display names are now possible
-while using SMTP.
-
-*** Content-Id ***
-
-It was pointed out by alex via CPAN RT that Content-Id needs to have angle brackets around
-it or HTML mails dont show up properly in many mail clients, furthermore the RFC mandates it
-(to be honest im taking his word on this, please feel free to yell at me if this causes trouble),
-so as he suggested I am automatically adding them in they arent provided.
-
-*** sendmail path ***
-
-Dom pointed out via CPAN RT that despite some effort going in to trying to discover the correct
-location of sendmail, that it was still using a bad default. Fixed.
-
-*** Date Stamping ***
-
-Kurt reported via RT that datestamps were not being correctly formatted. His patch has been incorporated
-with only one change, a comment where Perl was spelled PERL :-)
-
-*** Quoted printable fix ***
-
-Klaus Rusch noted a bug in how quoted-printable handled weird \r\n combinations. Fixed now.
-
-=item Version 3.01 (2003/04/25)
-
-Eryq has reappeared long enough to graciously hand over the maintaince of the
-module to me. Thanks.
-
-=item Version 3.00 (2003/04/24)
-
-Eryq has disappeared. His web site remains but he doesnt answer emails.
-
-I have taken it onto myself to take over maintenance until he returns to
-reclaim his excellent work.
-
-I don't intend to develop this in an serious way. I'll patch it if people
-have a patch and generally keep it ticking over, but dont expect new features.
-
-This release has code that actually works with MIME::Lite now. As well as a few
-other minor additions (like a test for this functionailty)
-
-For stuff that could be done, a first place would be to rewrite and extend the
-test suite. It should use Test::More or Test::Builder at the very least.
-
-I also might rip out the preformatted doc pages. It makes the distro way fatter
-than it needs to be. I reckon the package contains the POD in at least three forms.
-A wee tad overkill I think. :-)
-
-=item Version 2.117 (2001/08/20)
-
-The terms-of-use have been placed in the distribution file "COPYING".
-Also, small documentation tweaks were made.
-
-
-=item Version 2.116 (2001/08/17)
-
-Added long-overdue patch which makes the instance method form
-of send() do the right thing when given HOW... arguments.
-I<Thanks to Casey West for the patch.>
-
-=item Version 2.114 (2001/08/16)
-
-New special 'AUTO' content type in new()/build() tells MIME::Lite to
-try and guess the type from file extension. To make use of
-this, you'll want to install B<MIME::Types>.
-The "AUTO" setting can be made the default default (instead of "TEXT")
-if you set C<$AUTO_CONTENT_TYPE = 1, $PARANOID = 0>.
-I<Thanks to> Ville SkyttE<228> I<for these patches.>
-
-File::Basename is used if it is available.
-I<Thanks to> Ville SkyttE<228> I<for this patch.>
-
-SMTP failures (in send_by_smtp) now add the $smtp-E<gt>message to the
-croak'ed exception, so if things go wrong, you get a better
-idea of what and why.
-I<Thanks to Thomas R. Wyant III for the patch.>
-
-Made a subtle change to C<as_string> which supposedly fixes a
-failed MIME data.t test with Perl 5.004_04 on NT 4 sp6.
-The problem might only exist in this old perl, but as the patch
-author says, not everyone has climbed higher on the Perl ladder.
-I<Thanks to John Gotts for the patch.>
-
-Added C<contrib> directory, with F<MailTool.pm>.
-I<Thanks to Tom Wyant for this contribution.>
-
-Improved HTML documentation (notice the links to
-the individual methods in the top menu).
-
-Corrected some mis-docs.
-
-
-=item Version 2.111 (2001/04/03)
-
-Added long-overdue C<parts()> and C<parts_DFS()> methods.
-
- No instance method
- For accessing the subparts?
- That can't be right. D'OH!
-
-Added long-overdue auto-verify logic to C<print()> method.
-
-Added long-overdue C<preamble()> method for getting/setting
-the preamble text.
-I<Thanks to Jim Daigle for inspiring this.>
-
-
-=item Version 2.108 (2001/03/30)
-
-New C<field_order()> allows you to set the header order, both on a
-per-message basis, and package-wide.
-I<Thanks to Thomas Stromberg for suggesting this.>
-
-Added code to try and divine "sendmail" path more intelligently.
-I<Thanks to Slaven Rezic for the suggestion.>
-
-
-=item Version 2.107 (2001/03/27)
-
-Fixed serious bug where tainted data with quoted-printable encoding
-was causing infinite loops. The "fix" untaints the data in question,
-which is not optimal, but it's probably benign in this case.
-I<Thanks to Stefan Sautter for tracking this nasty little beast down.>
-I<Thanks to Larry Geralds for a related patch.>
-
- "Doctor, O doctor:
- it's painful when I do *this* --"
- "Simple: don't *do* that."
-
-Fixed bugs where a non-local C<$_> was being modified... again!
-Will I never learn?
-I<Thanks to Maarten Koskamp for reporting this.>
-
- Dollar-underscore
- can poison distant waters;
- 'local' must it be.
-
-Fixed buglet in C<add()> where all value references were being treated
-as arrayrefs, instead of as possibly-self-stringifying object refs.
-Now you can send in an object ref as the 2nd argument.
-I<Thanks to dLux for the bug report.>
-
- That ref is a string?
- Operator overload
- has ruined my day.
-
-Added "Approved" as an acceptable header field for C<new()>, as per RFC1036.
-I<Thanks to Thomax for the suggestion regarding MIME-tools.>
-
-Small improvements to docs to make different uses of attach()
-and various arguments clearer.
-I<Thanks to Sven Rassman and Roland Walter for the suggestions.>
-
-
-=item Version 2.106 (2000/11/21)
-
-Added Alpha version of scrub() to make it easy for people to suppress
-the printing of unwanted MIME attributes (like Content-length).
-I<Thanks to the many people who asked for this.>
-
-Headers with empty-strings for their values are no longer
-printed. This seems sensible, and helps us implement scrub().
-
-
-=item Version 2.105 (2000/10/14)
-
-The regression-test failure was identified, and it was my fault.
-Apparently some of the \-quoting in my "autoloaded" code was
-making Perl 5.6 unhappy. For this nesting-related idiocy,
-a nesting kaiku.
-I<Thanks to Scott Schwartz for identifying the problem.>
-
- In a pattern, my
- backslash-s dwells peacefully,
- unambiguous --
-
- but I embed it
- in a double-quoted string
- doubling the backslash --
-
- interpolating
- that same double-quoted string
- in other patterns --
-
- and, worlds within worlds,
- I single-quote the function
- to autoload it --
-
- changing the meaning
- of the backslash and the 's';
- and Five-Point-Six growls.
-
-
-=item Version 2.104 (2000/09/28)
-
-Now attempts to load and use Mail::Address for parsing email
-addresses I<before> falling back to our own method.
-I<Thanks to numerous people for suggesting this.>
-
- Parsing addresses
- is too damn hard. One last hope:
- Let Graham Barr do it!
-
-For the curious, the version of Mail::Address appears
-as the "A" number in the X-Mailer:
-
- X-Mailer: MIME::Lite 2.104 (A1.15; B2.09; Q2.03)
-
-Added B<FromSender> option to send_by_sendmail().
-I<Thanks to Bill Moseley for suggesting this feature.>
-
-
-=item Version 2.101 (2000/06/06)
-
-Major revision to print_body() and body_as_string() so that
-"body" really means "the part after the header", which is what most
-people would want in this context. This is B<not> how it was used
-1.x, where "body" only meant "the body of a simple singlepart".
-Hopefully, this change will solve many problems and create very few ones.
-
-Added support for attaching a part to a "message/rfc822", treating
-the "message" type as a multipart-like container.
-
-Now takes care not to include "Bcc:" in header when using send_by_smtp,
-as a safety precaution against qmail's behavior.
-I<Thanks to Tatsuhiko Miyagawa for identifying this problem.>
-
-Improved efficiency of many stringifying operations by using
-string-arrays which are joined, instead of doing multiple appends
-to a scalar.
-
-Cleaned up the "examples" directory.
-
-
-=item Version 1.147 (2000/06/02)
-
-Fixed buglet where lack of Cc:/Bcc: was causing extract_addrs
-to emit "undefined variable" warnings. Also, lack of a "To:" field
-now causes a croak.
-I<Thanks to David Mitchell for the bug report and suggested patch.>
-
-
-=item Version 1.146 (2000/05/18)
-
-Fixed bug in parsing of addresses; please read the WARNINGS section
-which describes recommended address formats for "To:", "Cc:", etc.
-Also added automatic inclusion of a UT "Date:" at top level unless
-explicitly told not to.
-I<Thanks to Andy Jacobs for the bug report and the suggestion.>
-
-=item Version 1.145 (2000/05/06)
-
-Fixed bug in encode_7bit(): a lingering C</e> modifier was removed.
-I<Thanks to Michael A. Chase for the patch.>
-
-
-=item Version 1.142 (2000/05/02)
-
-Added new, taint-safe invocation of "sendmail", one which also
-sets up the C<-f> option. Unfortunately, I couldn't make this automatic:
-the change could have broken a lot of code out there which used
-send_by_sendmail() with unusual "sendmail" variants.
-So you'll have to configure "send" to use the new mechanism:
-
- MIME::Lite->send('sendmail'); ### no args!
-
-I<Thanks to Jeremy Howard for suggesting these features.>
-
-
-=item Version 1.140 (2000/04/27)
-
-Fixed bug in support for "To", "Cc", and "Bcc" in send_by_smtp():
-multiple (comma-separated) addresses should now work fine.
-We try real hard to extract addresses from the flat text strings.
-I<Thanks to John Mason for motivating this change.>
-
-Added automatic verification that attached data files exist,
-done immediately before the "send" action is invoked.
-To turn this off, set $MIME::Lite::AUTO_VERIFY to false.
-
-=item Version 1.137 (2000/03/22)
-
-Added support for "Cc" and "Bcc" in send_by_smtp().
-To turn this off, set $MIME::Lite::AUTO_CC to false.
-I<Thanks to Lucas Maneos for the patch, and tons of others for
-the suggestion.>
-
-Chooses a better default content-transfer-encoding if the content-type
-is "image/*", "audio/*", etc.
-To turn this off, set $MIME::Lite::AUTO_ENCODE to false.
-I<Thanks to many folks for the suggestion.>
-
-Fixed bug in QP-encoding where a non-local C<$_> was being modified.
-I<Thanks to Jochen Stenzel for finding this very obscure bug!>
-
-Removed references to C<$`>, C<$'>, and C<$&> (bad variables
-which slow things down).
-
-Added an example of how to send HTML files with enclosed in-line
-images, per popular demand.
-
-
-=item Version 1.133 (1999/04/17)
-
-Fixed bug in "Data" handling: arrayrefs were not being handled
-properly.
-
-
-=item Version 1.130 (1998/12/14)
-
-Added much larger and more-flexible send() facility.
-I<Thanks to Andrew McRae (and Optimation New Zealand Ltd)
-for the Net::SMTP interface. Additional thanks to the many folks
-who requested this feature.>
-
-Added get() method for extracting basic attributes.
-
-New... "t" tests!
-
-
-=item Version 1.124 (1998/11/13)
-
-Folded in filehandle (FH) support in build/attach.
-I<Thanks to Miko O'Sullivan for the code.>
-
-
-=item Version 1.122 (1998/01/19)
-
-MIME::Base64 and MIME::QuotedPrint are used if available.
-
-The 7bit encoding no longer does "escapes"; it merely strips 8-bit characters.
-
-
-=item Version 1.121 (1997/04/08)
-
-Filename attribute is now no longer ignored by build().
-I<Thanks to Ian Smith for finding and patching this bug.>
-
-
-=item Version 1.120 (1997/03/29)
-
-Efficiency hack to speed up MIME::Lite::IO_Scalar.
-I<Thanks to David Aspinwall for the patch.>
-
-
-=item Version 1.116 (1997/03/19)
-
-Small bug in our private copy of encode_base64() was patched.
-I<Thanks to Andreas Koenig for pointing this out.>
-
-New, prettier way of specifying mail message headers in C<build()>.
-
-New quiet method to turn off warnings.
-
-Changed "stringify" methods to more-standard "as_string" methods.
-
-
-=item Version 1.112 (1997/03/06)
-
-Added C<read_now()>, and C<binmode()> method for our non-Unix-using brethren:
-file data is now read using binmode() if appropriate.
-I<Thanks to Xiangzhou Wang for pointing out this bug.>
-
-
-=item Version 1.110 (1997/03/06)
-
-Fixed bug in opening the data filehandle.
-
-
-=item Version 1.102 (1997/03/01)
-
-Initial release.
-
-
-=item Version 1.101 (1997/03/01)
-
-Baseline code.
-Originally created: 11 December 1996. Ho ho ho.
-
-=back
+=head1 CHANGE LOG
+
+=over 4
+
+=item Version 3.01_04 (2004/05/05)
+
+Reworked the new send_by_smtp stuff. Documentation modifications.
+
+=item Version 3.01_02 (2003/08/28)
+
+Well, it seems 3.01_01 failed tests on Win32 due to me accidentally changing the line ending
+format to DOSish. Also the way that email extraction for SMTP with or without Mail::Address
+was different (from 2.117 even). So ive fixed that.
+
+Anybody depending on the undocumented extract_addrs() is in for a suprise. I suggest you look
+at using Mail::Address.
+
+=item Version 3.01_01 (2003/04/25 - 2003/08/21)
+
+(This version is a test release, if its ok then I'll re-release it as 3.02)
+
+Patched the pod to use correct entities Thanks to Ed Avis for the patch.
+Added better support for funky names in the from field when sending via SMTP, thanks to
+prodding by Darren Hemphill and Ollie Gallardo. (Actually I kind of messed this up orginally
+and no doubt Darren wasn't impressed. I ended up using something pretty close to his solution.
+My bad for not paying more attention. Sorry mate.)
+
+08/21: Apparently I never uploaded my changes for this version to CPAN. Sigh.
+
+*** Win32 CHANGES ***
+
+Up until this release the default send() method for all OS'es has been to invoke sendmail
+and pipe the mail to it. This behaviour has now changed on Win32 to default to using SMTP.
+This means that if your /site/lib/Net/libnet.cfg file is properly configured then you can
+use SMTP without specifying a send method explicitly. This seemed a rational decision as
+most Win32 users who send mails are using an SMTP server and not a tool like sendmail.
+
+*** SMTP CHANGES ***
+
+Jonathan Eunice <jeunice at illuminata dot com> pointed out an interesting bug in the
+interaction between MIME::Lite and Net::SMTP/Net::CMD. This was that sending a mail
+ending in "\n\n" without additional encoding would cause Net::CMD to send an incorrect
+end of mail signal to the SMTP server which would result in A) The mail failing to be sent due
+to a timeout, and B) MIME::Lite to report that all was well.
+
+This has been fixed by checking to make sure that if the last character sent was \n, but the
+last two chars were not \r\n then the \n is turned into an \r, which Net::CMD then adds an \n
+to and then sends the normal ".\r\n" to terminate the message. Weird error, that im not
+entirely sure has been resolved properly. Please inform me if this screws anything up that it
+shouldn't.
+
+As stated earlier send_by_smtp wasnt extracting the _real_ email address from the overall fancy
+once specified in the From: field. This is resolved now, fancy display names are now possible
+while using SMTP.
+
+*** Content-Id ***
+
+It was pointed out by alex via CPAN RT that Content-Id needs to have angle brackets around
+it or HTML mails dont show up properly in many mail clients, furthermore the RFC mandates it
+(to be honest im taking his word on this, please feel free to yell at me if this causes trouble),
+so as he suggested I am automatically adding them in they arent provided.
+
+*** sendmail path ***
+
+Dom pointed out via CPAN RT that despite some effort going in to trying to discover the correct
+location of sendmail, that it was still using a bad default. Fixed.
+
+*** Date Stamping ***
+
+Kurt reported via RT that datestamps were not being correctly formatted. His patch has been incorporated
+with only one change, a comment where Perl was spelled PERL :-)
+
+*** Quoted printable fix ***
+
+Klaus Rusch noted a bug in how quoted-printable handled weird \r\n combinations. Fixed now.
+
+=item Version 3.01 (2003/04/25)
+
+Eryq has reappeared long enough to graciously hand over the maintaince of the
+module to me. Thanks.
+
+=item Version 3.00 (2003/04/24)
+
+Eryq has disappeared. His web site remains but he doesnt answer emails.
+
+I have taken it onto myself to take over maintenance until he returns to
+reclaim his excellent work.
+
+I don't intend to develop this in an serious way. I'll patch it if people
+have a patch and generally keep it ticking over, but dont expect new features.
+
+This release has code that actually works with MIME::Lite now. As well as a few
+other minor additions (like a test for this functionailty)
+
+For stuff that could be done, a first place would be to rewrite and extend the
+test suite. It should use Test::More or Test::Builder at the very least.
+
+I also might rip out the preformatted doc pages. It makes the distro way fatter
+than it needs to be. I reckon the package contains the POD in at least three forms.
+A wee tad overkill I think. :-)
+
+=item Version 2.117 (2001/08/20)
+
+The terms-of-use have been placed in the distribution file "COPYING".
+Also, small documentation tweaks were made.
+
+
+=item Version 2.116 (2001/08/17)
+
+Added long-overdue patch which makes the instance method form
+of send() do the right thing when given HOW... arguments.
+I<Thanks to Casey West for the patch.>
+
+=item Version 2.114 (2001/08/16)
+
+New special 'AUTO' content type in new()/build() tells MIME::Lite to
+try and guess the type from file extension. To make use of
+this, you'll want to install B<MIME::Types>.
+The "AUTO" setting can be made the default default (instead of "TEXT")
+if you set C<$AUTO_CONTENT_TYPE = 1, $PARANOID = 0>.
+I<Thanks to> Ville SkyttE<228> I<for these patches.>
+
+File::Basename is used if it is available.
+I<Thanks to> Ville SkyttE<228> I<for this patch.>
+
+SMTP failures (in send_by_smtp) now add the $smtp-E<gt>message to the
+croak'ed exception, so if things go wrong, you get a better
+idea of what and why.
+I<Thanks to Thomas R. Wyant III for the patch.>
+
+Made a subtle change to C<as_string> which supposedly fixes a
+failed MIME data.t test with Perl 5.004_04 on NT 4 sp6.
+The problem might only exist in this old perl, but as the patch
+author says, not everyone has climbed higher on the Perl ladder.
+I<Thanks to John Gotts for the patch.>
+
+Added C<contrib> directory, with F<MailTool.pm>.
+I<Thanks to Tom Wyant for this contribution.>
+
+Improved HTML documentation (notice the links to
+the individual methods in the top menu).
+
+Corrected some mis-docs.
+
+
+=item Version 2.111 (2001/04/03)
+
+Added long-overdue C<parts()> and C<parts_DFS()> methods.
+
+ No instance method
+ For accessing the subparts?
+ That can't be right. D'OH!
+
+Added long-overdue auto-verify logic to C<print()> method.
+
+Added long-overdue C<preamble()> method for getting/setting
+the preamble text.
+I<Thanks to Jim Daigle for inspiring this.>
+
+
+=item Version 2.108 (2001/03/30)
+
+New C<field_order()> allows you to set the header order, both on a
+per-message basis, and package-wide.
+I<Thanks to Thomas Stromberg for suggesting this.>
+
+Added code to try and divine "sendmail" path more intelligently.
+I<Thanks to Slaven Rezic for the suggestion.>
+
+
+=item Version 2.107 (2001/03/27)
+
+Fixed serious bug where tainted data with quoted-printable encoding
+was causing infinite loops. The "fix" untaints the data in question,
+which is not optimal, but it's probably benign in this case.
+I<Thanks to Stefan Sautter for tracking this nasty little beast down.>
+I<Thanks to Larry Geralds for a related patch.>
+
+ "Doctor, O doctor:
+ it's painful when I do *this* --"
+ "Simple: don't *do* that."
+
+Fixed bugs where a non-local C<$_> was being modified... again!
+Will I never learn?
+I<Thanks to Maarten Koskamp for reporting this.>
+
+ Dollar-underscore
+ can poison distant waters;
+ 'local' must it be.
+
+Fixed buglet in C<add()> where all value references were being treated
+as arrayrefs, instead of as possibly-self-stringifying object refs.
+Now you can send in an object ref as the 2nd argument.
+I<Thanks to dLux for the bug report.>
+
+ That ref is a string?
+ Operator overload
+ has ruined my day.
+
+Added "Approved" as an acceptable header field for C<new()>, as per RFC1036.
+I<Thanks to Thomax for the suggestion regarding MIME-tools.>
+
+Small improvements to docs to make different uses of attach()
+and various arguments clearer.
+I<Thanks to Sven Rassman and Roland Walter for the suggestions.>
+
+
+=item Version 2.106 (2000/11/21)
+
+Added Alpha version of scrub() to make it easy for people to suppress
+the printing of unwanted MIME attributes (like Content-length).
+I<Thanks to the many people who asked for this.>
+
+Headers with empty-strings for their values are no longer
+printed. This seems sensible, and helps us implement scrub().
+
+
+=item Version 2.105 (2000/10/14)
+
+The regression-test failure was identified, and it was my fault.
+Apparently some of the \-quoting in my "autoloaded" code was
+making Perl 5.6 unhappy. For this nesting-related idiocy,
+a nesting kaiku.
+I<Thanks to Scott Schwartz for identifying the problem.>
+
+ In a pattern, my
+ backslash-s dwells peacefully,
+ unambiguous --
+
+ but I embed it
+ in a double-quoted string
+ doubling the backslash --
+
+ interpolating
+ that same double-quoted string
+ in other patterns --
+
+ and, worlds within worlds,
+ I single-quote the function
+ to autoload it --
+
+ changing the meaning
+ of the backslash and the 's';
+ and Five-Point-Six growls.
+
+
+=item Version 2.104 (2000/09/28)
+
+Now attempts to load and use Mail::Address for parsing email
+addresses I<before> falling back to our own method.
+I<Thanks to numerous people for suggesting this.>
+
+ Parsing addresses
+ is too damn hard. One last hope:
+ Let Graham Barr do it!
+
+For the curious, the version of Mail::Address appears
+as the "A" number in the X-Mailer:
+
+ X-Mailer: MIME::Lite 2.104 (A1.15; B2.09; Q2.03)
+
+Added B<FromSender> option to send_by_sendmail().
+I<Thanks to Bill Moseley for suggesting this feature.>
+
+
+=item Version 2.101 (2000/06/06)
+
+Major revision to print_body() and body_as_string() so that
+"body" really means "the part after the header", which is what most
+people would want in this context. This is B<not> how it was used
+1.x, where "body" only meant "the body of a simple singlepart".
+Hopefully, this change will solve many problems and create very few ones.
+
+Added support for attaching a part to a "message/rfc822", treating
+the "message" type as a multipart-like container.
+
+Now takes care not to include "Bcc:" in header when using send_by_smtp,
+as a safety precaution against qmail's behavior.
+I<Thanks to Tatsuhiko Miyagawa for identifying this problem.>
+
+Improved efficiency of many stringifying operations by using
+string-arrays which are joined, instead of doing multiple appends
+to a scalar.
+
+Cleaned up the "examples" directory.
+
+
+=item Version 1.147 (2000/06/02)
+
+Fixed buglet where lack of Cc:/Bcc: was causing extract_addrs
+to emit "undefined variable" warnings. Also, lack of a "To:" field
+now causes a croak.
+I<Thanks to David Mitchell for the bug report and suggested patch.>
+
+
+=item Version 1.146 (2000/05/18)
+
+Fixed bug in parsing of addresses; please read the WARNINGS section
+which describes recommended address formats for "To:", "Cc:", etc.
+Also added automatic inclusion of a UT "Date:" at top level unless
+explicitly told not to.
+I<Thanks to Andy Jacobs for the bug report and the suggestion.>
+
+=item Version 1.145 (2000/05/06)
+
+Fixed bug in encode_7bit(): a lingering C</e> modifier was removed.
+I<Thanks to Michael A. Chase for the patch.>
+
+
+=item Version 1.142 (2000/05/02)
+
+Added new, taint-safe invocation of "sendmail", one which also
+sets up the C<-f> option. Unfortunately, I couldn't make this automatic:
+the change could have broken a lot of code out there which used
+send_by_sendmail() with unusual "sendmail" variants.
+So you'll have to configure "send" to use the new mechanism:
+
+ MIME::Lite->send('sendmail'); ### no args!
+
+I<Thanks to Jeremy Howard for suggesting these features.>
+
+
+=item Version 1.140 (2000/04/27)
+
+Fixed bug in support for "To", "Cc", and "Bcc" in send_by_smtp():
+multiple (comma-separated) addresses should now work fine.
+We try real hard to extract addresses from the flat text strings.
+I<Thanks to John Mason for motivating this change.>
+
+Added automatic verification that attached data files exist,
+done immediately before the "send" action is invoked.
+To turn this off, set $MIME::Lite::AUTO_VERIFY to false.
+
+=item Version 1.137 (2000/03/22)
+
+Added support for "Cc" and "Bcc" in send_by_smtp().
+To turn this off, set $MIME::Lite::AUTO_CC to false.
+I<Thanks to Lucas Maneos for the patch, and tons of others for
+the suggestion.>
+
+Chooses a better default content-transfer-encoding if the content-type
+is "image/*", "audio/*", etc.
+To turn this off, set $MIME::Lite::AUTO_ENCODE to false.
+I<Thanks to many folks for the suggestion.>
+
+Fixed bug in QP-encoding where a non-local C<$_> was being modified.
+I<Thanks to Jochen Stenzel for finding this very obscure bug!>
+
+Removed references to C<$`>, C<$'>, and C<$&> (bad variables
+which slow things down).
+
+Added an example of how to send HTML files with enclosed in-line
+images, per popular demand.
+
+
+=item Version 1.133 (1999/04/17)
+
+Fixed bug in "Data" handling: arrayrefs were not being handled
+properly.
+
+
+=item Version 1.130 (1998/12/14)
+
+Added much larger and more-flexible send() facility.
+I<Thanks to Andrew McRae (and Optimation New Zealand Ltd)
+for the Net::SMTP interface. Additional thanks to the many folks
+who requested this feature.>
+
+Added get() method for extracting basic attributes.
+
+New... "t" tests!
+
+
+=item Version 1.124 (1998/11/13)
+
+Folded in filehandle (FH) support in build/attach.
+I<Thanks to Miko O'Sullivan for the code.>
+
+
+=item Version 1.122 (1998/01/19)
+
+MIME::Base64 and MIME::QuotedPrint are used if available.
+
+The 7bit encoding no longer does "escapes"; it merely strips 8-bit characters.
+
+
+=item Version 1.121 (1997/04/08)
+
+Filename attribute is now no longer ignored by build().
+I<Thanks to Ian Smith for finding and patching this bug.>
+
+
+=item Version 1.120 (1997/03/29)
+
+Efficiency hack to speed up MIME::Lite::IO_Scalar.
+I<Thanks to David Aspinwall for the patch.>
+
+
+=item Version 1.116 (1997/03/19)
+
+Small bug in our private copy of encode_base64() was patched.
+I<Thanks to Andreas Koenig for pointing this out.>
+
+New, prettier way of specifying mail message headers in C<build()>.
+
+New quiet method to turn off warnings.
+
+Changed "stringify" methods to more-standard "as_string" methods.
+
+
+=item Version 1.112 (1997/03/06)
+
+Added C<read_now()>, and C<binmode()> method for our non-Unix-using brethren:
+file data is now read using binmode() if appropriate.
+I<Thanks to Xiangzhou Wang for pointing out this bug.>
+
+
+=item Version 1.110 (1997/03/06)
+
+Fixed bug in opening the data filehandle.
+
+
+=item Version 1.102 (1997/03/01)
+
+Initial release.
+
+
+=item Version 1.101 (1997/03/01)
+
+Baseline code.
+Originally created: 11 December 1996. Ho ho ho.
+
+=back
View
644 contrib/MailTool.pm
@@ -1,322 +1,322 @@
-#!/usr/bin/perl
-
-=head1 NAME
-
-MailTool - Handy-dandy MIME mailing class
-
-=head1 SYNOPSIS
-
- use lib some_directory, depending on where you put the .pm files
- use MailTool;
- $msg = MailTool->build (
- To => 'Justin.L.Heuser@usa.dupont.com',
- From => 'Harcourt.F.Mudd@usa.dupont.com',
- Subject => 'The check is in the mail',
- Path => standard_reply.txt,
- );
- $msg->send ();
-
-=head1 DESCRIPTION
-
-The MailTool class is actually a subclass of MIME::Lite. It provides
-no new methods, but does 'enhance' (I hope!) some of the existing
-ones. The natures of the enhancements (if enhancements they be) are:
-
-=head2 The default send method is now smtp.
-
-This may not be an enhancement if you're running Unix. The default
-of MIME::Lite is (or was when I wrote this) to spawn SENDMAIL.
-
-=head2 The SMTP host can be specified any number of ways.
-
-If you are using the send method, and are in fact using SMTP (i.e. you
-have not used the class send method to change the default way to send
-mail), the SMTP host comes from the first thing in the following list
-that is actually defined:
-
- The second argument of the class send method;
- The contents of environment variable SMTPHOSTS;
- The contents of smtp_hosts in Net::Config;
- The name of the host that is executing the script.
-
-If you are calling send_by_smtp explicitly, the information specified
-to the class send method is ignored (because this is consistent with
-the behaviour of MIME::Lite), and the SMTP host is determined by the
-first thing in the following list that is actually defined:
-
- The first argument passed to send_by_smtp;
- The contents of environment variable SMTPHOSTS;
- The contents of smtp_hosts in Net::Config;
- The name of the host that is executing the script.
-
-Multiple SMTP hosts can be specified, either by passing a reference,
-or by separating the names by colons (the normal way of specifying
-SMTPHOSTS, which is used by Mail::Internet). If you specify multiple
-hosts, they are tried in the order specified until the send succeeds
-or the list of hosts is exhausted. In the latter case, an exception
-is raised which describes the last error encountered.
-
-Specifying multiple hosts while using a send method other than smtp
-is unsupported.
-
-=head2 Mailing lists are supported.
-
-Any address element that begins with an "@" sign is assumed to be
-a reference to a mailing list, with the rest of the address element
-being the name of the file. This file is opened and read, and any
-and all lines in the file are appended to the address list. This
-functionality works for the "To", "Cc", and "Bcc" tags only.
-
-=head2 You get an error message back if send_by_smtp fails.
-
-This message is the first error encountered in the attempt to send
-using the last host on the list.
-
-=head1 REQUIREMENTS
-
-The following Perl modules are required:
- Carp (standard module)
- FileHandle (standard module)
- Mail::Address (from library MailTools)
- MIME::Lite (from library MIME-lite)
- Net::Config (from library libnet)
- Net::SMTP (from library libnet)
- Sys::Hostname (standard module)
-
-Note that these in turn can have requirements of their own. What these
-requirements are is best found by reading the documentation for the
-libraries themselves, but you can pretty much count on needing at least
- MIME::Base64 (from MIME-base64). On the other hand, the only known new
-nonstandard requirement (over and above those of MIME::Lite) are
-Mail::Address (because I was lazier than Eryq, and didn't provide a
-hack to cover its absence). Truth to tell, Net::Config is also new, but
-if you have Net::SMTP you should have Net::Config as well.
-
-=over 4
-
-=cut
-
-package MailTool;
-
-use strict;
-use vars qw{@ISA $Debug};
-use Carp;
-use FileHandle;
-use Mail::Address;
-use MIME::Lite;
-use Net::Config;
-use Net::SMTP;
-use Sys::Hostname;
-
-@ISA = qw{MIME::Lite};
-
-my %handler = (
- bcc => \&_map_addr,
- cc => \&_map_addr,
- to => \&_map_addr,
- );
-
-# Make the default method SMTP.
-
-MailTool->send ('smtp');
-
-
-=item $msg->add (tag, value)
-
-This override of MIME::Light::add is the hook where mailing list
-functionality is provided.
-
-It looks up the tag being added in its internal hash table. If a hit
-is found, both tag and value are passed to the subroutine specified
-in the hash table, and the value returned is passed to SUPER::add. If
-no hit is found, the pristine value is passed to SUPER::add.
-
-In the case of the 'to', 'cc', and 'bcc' tags, the effect is to
-try to expand all addresses beginning with "@" as mailing lists.
-No other tags are currently munged.
-
-=cut
-
-sub add {
-my $self = shift;
-my $tag = lc(shift);
-my $value = shift;
-$value = &{$handler{$tag}} ($self, $tag, $value)
- if exists $handler{$tag};
-$self->SUPER::add ($tag, $value);
-}
-
-
-=item $msg->send_by_smtp ([smtp_host])
-
-This override of MIME::Lite's send_by_smtp method does pretty much the
-same thing (it should! the code was stolen shamelessly! Thanks, Eryq!)
-It has, however, the following differences:
-
- * More error detail (sometimes)
- * Sensitivity to a number of sources of SMTP server information:
- - Explicitly in the argument(s) to the method;
- - From environment variable SMTPHOSTS (colon-separated list);
- - From Net::Config;
- - If all else fails, use the local machine.
-
-=cut
-
-sub send_by_smtp {
-my ($self, @args) = @_;
-
-# Get the SMTP hosts we're to use. We do multiple calls to
-# _get_hosts to prevent evaluating any more arguments than
-# necessary. Whether this makes any real difference, deponent
-# sayeth not.
-my $host_list = _get_hosts (shift @args) ||
- _get_hosts ($ENV{SMTPHOSTS}) ||
- _get_hosts ($NetConfig{smtp_hosts}) ||
- _get_hosts (hostname ()) or
- croak "send_by_smtp: cannot determine smtp host\n";
-croak "send_by_smtp: host list is empty; this should never happen.\n"
- unless @$host_list;
-
-# We need the "From:" and "To:" headers to pass to the
-# SMTP mailer:
-my $from = $self->get('From');
-my $to = $self->get('To');
-
-# Sanity check:
-defined($to) or croak "send_by_smtp: missing 'To:' address\n";
-
-# Get the destinations as a simple array of addresses.
-my @to_all = map {$_->format} Mail::Address->parse ($to);
-
-# Duplicate the superclass' cc functionality.
-if ($MIME::Lite::AUTO_CC) {
- foreach my $field (qw(Cc Bcc)) {
- my $value = $self->get($field) or next;
- push @to_all, map {$_->format} Mail::Address->parse ($value);
- }
- }
-
-# Try each possible host.
-
-my ($smtp, $err);
-foreach my $svr (@$host_list) {
- print STDERR "Debug send_by_smtp - Trying SMTP host $svr\n" if $Debug;
- $smtp = Net::SMTP->new ($svr, @args) or do {
- $err = "Failed to connect to mail server $svr: $!\n";
- next; };
- $smtp->mail ($from) or do {
- $err = "SMTP MAIL command to $svr failed: $!\n" .
- $smtp->message ();
- next; };
- $smtp->to (@to_all) or do {
- $err = "SMTP RCPT command to $svr failed: $!\n" .
- $smtp->message ();
- next; };
- $smtp->data ($self->as_string ()) or do {
- $err = "SMTP DATA command to $svr failed: $!\n" .
- $smtp->message ();
- next; };
- $smtp->quit ();
- $err = '';
- print STDERR "Debug send_by_smtp - Host $svr succeeded.\n" if $Debug;
- last;
- }
- continue {
- print STDERR "Debug send_by_smtp - Host $svr failed: $err\n" if $Debug;
- $smtp->quit () if $smtp;
- }
-croak $err if $err;
-1;
-}
-
-
-########################################################################
-#
-# _get_hosts
-#
-# This subroutine figures out if any of its arguments represents
-# a host specification of any sort. If so, it returns a reference
-# to the list of hosts specified by the first such argument. If
-# not, it returns undef.
-
-sub _get_hosts {
-print STDERR "Debug _get_hosts (", join (', ',
- map {ref $_ ? '[' . (join (', ', map {"'$_'"} @$_)) . ']' : "'$_'"} @_),
- ")\n"
- if $Debug;
-foreach (@_) {
- next unless $_;
- return [split ':', $_] unless ref $_;
- return $_ if @$_;
- }
-return undef;
-}
-
-########################################################################
-#
-# _map_addr
-#
-# This subroutine expects the value passed in to look like a list
-# of mailing addresses. If any of the addresses looks like
-# "@xxxxx", everything except the initial "@" is assumed to be
-# the name of a file; this file is read and its records inserted
-# into the list of addressees. No attempt is made to eliminate
-# duplicates.
-
-sub _map_addr {
-my $self = shift;
-my $tag = lc shift;
-my $value = shift;
-my $ad_in = ref $value ? $value : [$value];
-my @ad_out;
-
-foreach (@$ad_in) {
- foreach (map {$_->format} Mail::Address->parse ($_)) {
- s/^\s+//;
- s/\s+$//;
- next unless $_;
- if (m/^\@(.+)/) {
- my $fn = $1;
- my $fh = FileHandle->new ("<$fn") or
- croak "Error - Cannot open mailing list $fn: $!";
- while (my $buf = $fh->getline ()) {
- chomp $buf;
- $buf =~ s/\#.*//;
- next unless $buf;
- push @$ad_in, map {$_->format} Mail::Address->parse ($buf)
- }
- $fh->close ();
- }
- else {
- push @ad_out, $_;
- }
- }
- }
-return @ad_out if wantarray;
-return \@ad_out if ref $value;
-return join ',', @ad_out;
-}
-
-
-=back
-
-=head1 COPYRIGHT
-
-Copyright 2001 by E. I. DuPont de Nemours and Company. All rights
-reserved.
-
-This library is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself.
-
-This software comes with no warranty whatsoever, either expressed
-or implied.
-
-=head1 AUTHOR
-
-Tom Wyant (F<Thomas.R.Wyant-III@usa.dupont.com>), E. I. DuPont de
-Nemours and Company, Inc. (F<http://www.dupont.com>, and no, you
-won't find anything about this module there).
-
-=cut
-
-1;
+#!/usr/bin/perl
+
+=head1 NAME
+
+MailTool - Handy-dandy MIME mailing class
+
+=head1 SYNOPSIS
+
+ use lib some_directory, depending on where you put the .pm files
+ use MailTool;
+ $msg = MailTool->build (
+ To => 'Justin.L.Heuser@usa.dupont.com',
+ From => 'Harcourt.F.Mudd@usa.dupont.com',
+ Subject => 'The check is in the mail',
+ Path => standard_reply.txt,
+ );
+ $msg->send ();
+
+=head1 DESCRIPTION
+
+The MailTool class is actually a subclass of MIME::Lite. It provides
+no new methods, but does 'enhance' (I hope!) some of the existing
+ones. The natures of the enhancements (if enhancements they be) are:
+
+=head2 The default send method is now smtp.
+
+This may not be an enhancement if you're running Unix. The default
+of MIME::Lite is (or was when I wrote this) to spawn SENDMAIL.
+
+=head2 The SMTP host can be specified any number of ways.
+
+If you are using the send method, and are in fact using SMTP (i.e. you
+have not used the class send method to change the default way to send
+mail), the SMTP host comes from the first thing in the following list
+that is actually defined:
+
+ The second argument of the class send method;
+ The contents of environment variable SMTPHOSTS;
+ The contents of smtp_hosts in Net::Config;
+ The name of the host that is executing the script.
+
+If you are calling send_by_smtp explicitly, the information specified
+to the class send method is ignored (because this is consistent with
+the behaviour of MIME::Lite), and the SMTP host is determined by the
+first thing in the following list that is actually defined:
+
+ The first argument passed to send_by_smtp;
+ The contents of environment variable SMTPHOSTS;
+ The contents of smtp_hosts in Net::Config;
+ The name of the host that is executing the script.
+
+Multiple SMTP hosts can be specified, either by passing a reference,
+or by separating the names by colons (the normal way of specifying
+SMTPHOSTS, which is used by Mail::Internet). If you specify multiple
+hosts, they are tried in the order specified until the send succeeds
+or the list of hosts is exhausted. In the latter case, an exception
+is raised which describes the last error encountered.
+
+Specifying multiple hosts while using a send method other than smtp
+is unsupported.
+
+=head2 Mailing lists are supported.
+
+Any address element that begins with an "@" sign is assumed to be
+a reference to a mailing list, with the rest of the address element
+being the name of the file. This file is opened and read, and any
+and all lines in the file are appended to the address list. This
+functionality works for the "To", "Cc", and "Bcc" tags only.
+
+=head2 You get an error message back if send_by_smtp fails.
+
+This message is the first error encountered in the attempt to send
+using the last host on the list.
+
+=head1 REQUIREMENTS
+
+The following Perl modules are required:
+ Carp (standard module)
+ FileHandle (standard module)
+ Mail::Address (from library MailTools)
+ MIME::Lite (from library MIME-lite)
+ Net::Config (from library libnet)
+ Net::SMTP (from library libnet)
+ Sys::Hostname (standard module)
+
+Note that these in turn can have requirements of their own. What these
+requirements are is best found by reading the documentation for the
+libraries themselves, but you can pretty much count on needing at least
+ MIME::Base64 (from MIME-base64). On the other hand, the only known new
+nonstandard requirement (over and above those of MIME::Lite) are
+Mail::Address (because I was lazier than Eryq, and didn't provide a
+hack to cover its absence). Truth to tell, Net::Config is also new, but
+if you have Net::SMTP you should have Net::Config as well.
+
+=over 4
+
+=cut
+
+package MailTool;
+
+use strict;
+use vars qw{@ISA $Debug};
+use Carp;
+use FileHandle;
+use Mail::Address;
+use MIME::Lite;
+use Net::Config;
+use Net::SMTP;
+use Sys::Hostname;
+
+@ISA = qw{MIME::Lite};
+
+my %handler = (
+ bcc => \&_map_addr,
+ cc => \&_map_addr,
+ to => \&_map_addr,
+ );
+
+# Make the default method SMTP.
+
+MailTool->send ('smtp');
+
+
+=item $msg->add (tag, value)
+
+This override of MIME::Light::add is the hook where mailing list
+functionality is provided.
+
+It looks up the tag being added in its internal hash table. If a hit
+is found, both tag and value are passed to the subroutine specified
+in the hash table, and the value returned is passed to SUPER::add. If
+no hit is found, the pristine value is passed to SUPER::add.
+
+In the case of the 'to', 'cc', and 'bcc' tags, the effect is to
+try to expand all addresses beginning with "@" as mailing lists.
+No other tags are currently munged.
+
+=cut
+
+sub add {
+my $self = shift;
+my $tag = lc(shift);
+my $value = shift;
+$value = &{$handler{$tag}} ($self, $tag, $value)
+ if exists $handler{$tag};
+$self->SUPER::add ($tag, $value);
+}
+
+
+=item $msg->send_by_smtp ([smtp_host])
+
+This override of MIME::Lite's send_by_smtp method does pretty much the
+same thing (it should! the code was stolen shamelessly! Thanks, Eryq!)
+It has, however, the following differences:
+
+ * More error detail (sometimes)
+ * Sensitivity to a number of sources of SMTP server information:
+ - Explicitly in the argument(s) to the method;
+ - From environment variable SMTPHOSTS (colon-separated list);
+ - From Net::Config;
+ - If all else fails, use the local machine.
+
+=cut
+
+sub send_by_smtp {
+my ($self, @args) = @_;
+
+# Get the SMTP hosts we're to use. We do multiple calls to
+# _get_hosts to prevent evaluating any more arguments than
+# necessary. Whether this makes any real difference, deponent
+# sayeth not.
+my $host_list = _get_hosts (shift @args) ||
+ _get_hosts ($ENV{SMTPHOSTS}) ||
+ _get_hosts ($NetConfig{smtp_hosts}) ||
+ _get_hosts (hostname ()) or
+ croak "send_by_smtp: cannot determine smtp host\n";
+croak "send_by_smtp: host list is empty; this should never happen.\n"
+ unless @$host_list;
+
+# We need the "From:" and "To:" headers to pass to the
+# SMTP mailer:
+my $from = $self->get('From');
+my $to = $self->get('To');
+
+# Sanity check:
+defined($to) or croak "send_by_smtp: missing 'To:' address\n";
+
+# Get the destinations as a simple array of addresses.
+my @to_all = map {$_->format} Mail::Address->parse ($to);
+
+# Duplicate the superclass' cc functionality.
+if ($MIME::Lite::AUTO_CC) {
+ foreach my $field (qw(Cc Bcc)) {
+ my $value = $self->get($field) or next;
+ push @to_all, map {$_->format} Mail::Address->parse ($value);
+ }
+ }
+
+# Try each possible host.
+
+my ($smtp, $err);
+foreach my $svr (@$host_list) {
+ print STDERR "Debug send_by_smtp - Trying SMTP host $svr\n" if $Debug;
+ $smtp = Net::SMTP->new ($svr, @args) or do {
+ $err = "Failed to connect to mail server $svr: $!\n";
+ next; };
+ $smtp->mail ($from) or do {
+ $err = "SMTP MAIL command to $svr failed: $!\n" .
+ $smtp->message ();
+ next; };
+ $smtp->to (@to_all) or do {
+ $err = "SMTP RCPT command to $svr failed: $!\n" .
+ $smtp->message ();
+ next; };
+ $smtp->data ($self->as_string ()) or do {
+ $err = "SMTP DATA command to $svr failed: $!\n" .
+ $smtp->message ();
+ next; };
+ $smtp->quit ();
+ $err = '';
+ print STDERR "Debug send_by_smtp - Host $svr succeeded.\n" if $Debug;
+ last;
+ }
+ continue {
+ print STDERR "Debug send_by_smtp - Host $svr failed: $err\n" if $Debug;
+ $smtp->quit () if $smtp;
+ }
+croak $err if $err;
+1;
+}
+
+
+########################################################################
+#
+# _get_hosts
+#
+# This subroutine figures out if any of its arguments represents
+# a host specification of any sort. If so, it returns a reference
+# to the list of hosts specified by the first such argument. If
+# not, it returns undef.
+
+sub _get_hosts {
+print STDERR "Debug _get_hosts (", join (', ',
+ map {ref $_ ? '[' . (join (', ', map {"'$_'"} @$_)) . ']' : "'$_'"} @_),
+ ")\n"
+ if $Debug;
+foreach (@_) {
+ next unless $_;
+ return [split ':', $_] unless ref $_;
+ return $_ if @$_;
+ }
+return undef;
+}
+
+########################################################################
+#
+# _map_addr
+#
+# This subroutine expects the value passed in to look like a list
+# of mailing addresses. If any of the addresses looks like
+# "@xxxxx", everything except the initial "@" is assumed to be
+# the name of a file; this file is read and its records inserted
+# into the list of addressees. No attempt is made to eliminate
+# duplicates.
+
+sub _map_addr {
+my $self = shift;
+my $tag = lc shift;
+my $value = shift;
+my $ad_in = ref $value ? $value : [$value];
+my @ad_out;
+
+foreach (@$ad_in) {
+ foreach (map {$_->format} Mail::Address->parse ($_)) {
+ s/^\s+//;
+ s/\s+$//;
+ next unless $_;
+ if (m/^\@(.+)/) {
+ my $fn = $1;
+ my $fh = FileHandle->new ("<$fn") or
+ croak "Error - Cannot open mailing list $fn: $!";
+ while (my $buf = $fh->getline ()) {
+ chomp $buf;
+ $buf =~ s/\#.*//;
+ next unless $buf;
+ push @$ad_in, map {$_->format} Mail::Address->parse ($buf)
+ }
+ $fh->close ();
+ }
+ else {
+ push @ad_out, $_;
+ }
+ }
+ }
+return @ad_out if wantarray;
+return \@ad_out if ref $value;
+return join ',', @ad_out;
+}
+
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright 2001 by E. I. DuPont de Nemours and Company. All rights
+reserved.
+
+This library is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+This software comes with no warranty whatsoever, either expressed
+or implied.
+
+=head1 AUTHOR
+
+Tom Wyant (F<Thomas.R.Wyant-III@usa.dupont.com>), E. I. DuPont de
+Nemours and Company, Inc. (F<http://www.dupont.com>, and no, you
+won't find anything about this module there).
+
+=cut
+
+1;
View
8 contrib/README
@@ -1,4 +1,4 @@
-Snippets in this directory have been contributed
-by users of MIME::Lite. Please don't email me
-with questions or comments; I'm not the maintainer...
-I'm just passing them on.
+Snippets in this directory have been contributed
+by users of MIME::Lite. Please don't email me
+with questions or comments; I'm not the maintainer...
+I'm just passing them on.
View
138 examples/mime_fwd
@@ -1,69 +1,69 @@
-#!/usr/bin/perl -w
-
-
-=head1 NAME
-
-mime_fwd - test the ability to embed messages
-
-
-=head1 SYNOPSIS
-
-Usage:
-
- mime_fwd
-
-
-=head1 DESCRIPTION
-
-Create a simple message, then wrap it in a "forward" and
-then a "reply".
-
-
-=head1 AUTHOR
-
-Eryq, eryq@zeegee.com
-
-=cut
-
-use strict;
-use MIME::Lite;
-use Getopt::Std;
-
-#------------------------------
-# main
-#------------------------------
-sub main {
- my %opts;
- my $subj = "hello world";
-
- ### Create a message:
- my $msg = MIME::Lite->new(From => 'user0',
- To => 'user1',
- Subject => $subj,
- Type => 'TEXT',
- Data => ["This is the original message.\n",
- "Let's see if we can embed it!\n"]);
-
- ### Forward it:
- my $fwd = MIME::Lite->new(From => 'user1',
- To => 'user2',
- Subject => ("Fwd: ".$msg->get('subject')),
- Type => 'message/rfc822');
- $fwd->attach($msg);
-
- ### Reply:
- my $re = MIME::Lite->new(From => 'user2',
- To => 'user0',
- Bcc => 'archives',
- Subject => ("Re: ".$fwd->get('subject')),
- Type => 'message/rfc822');
- $re->attach($fwd);
-
- ### Output!
- $re->print;
-}
-exit (&main ? 0 : -1);
-
-__END__
-
-
+#!/usr/bin/perl -w
+
+
+=head1 NAME
+
+mime_fwd - test the ability to embed messages
+
+
+=head1 SYNOPSIS
+
+Usage:
+
+ mime_fwd
+
+
+=head1 DESCRIPTION
+
+Create a simple message, then wrap it in a "forward" and
+then a "reply".
+
+
+=head1 AUTHOR
+
+Eryq, eryq@zeegee.com
+
+=cut
+
+use strict;
+use MIME::Lite;
+use Getopt::Std;
+
+#------------------------------
+# main
+#------------------------------
+sub main {
+ my %opts;
+ my $subj = "hello world";
+
+ ### Create a message:
+ my $msg = MIME::Lite->new(From => 'user0',
+ To => 'user1',
+ Subject => $subj,
+ Type => 'TEXT',
+ Data => ["This is the original message.\n",
+ "Let's see if we can embed it!\n"]);
+
+ ### Forward it:
+ my $fwd = MIME::Lite->new(From => 'user1',
+ To => 'user2',
+ Subject => ("Fwd: ".$msg->get('subject')),
+ Type => 'message/rfc822');
+ $fwd->attach($msg);
+
+ ### Reply:
+ my $re = MIME::Lite->new(From => 'user2',
+ To => 'user0',
+ Bcc => 'archives',
+ Subject => ("Re: ".$fwd->get('subject')),
+ Type => 'message/rfc822');
+ $re->attach($fwd);
+
+ ### Output!
+ $re->print;
+}
+exit (&main ? 0 : -1);
+
+__END__
+
+
View
186 examples/mime_gif
@@ -1,93 +1,93 @@
-#!/usr/bin/perl -w
-
-=head1 NAME
-
-mime_gif - encode a single gif by reading data different ways
-
-
-=head1 SYNOPSIS
-
-Usage:
-
- mime_gif /path/to/some.gif
-
-
-=head1 DESCRIPTION
-
-Encode a multipart message where each part contains the same GIF
-file, but where the GIF file has been read-in in different ways.
-The subject line of each part will tell you how the GIF was read.
-
-
-=head1 AUTHOR
-
-Eryq, eryq@zeegee.com
-
-=cut
-
-use strict;
-use MIME::Lite;
-use Getopt::Std;
-
-#------------------------------
-# main
-#------------------------------
-sub main {
- my %opts;
-
- ### Get options:
- getopts('', \%opts) or die "usage error\n";
- my $gifpath = $ARGV[0] || die "missing path to GIF\n";
-
- ### Create message:
- my $msg = MIME::Lite->new(To => 'me@somewhere.com',
- Subject => 'GIF test',
- Type => 'multipart/mixed');
-
- ### Read data:
- open IN, "<$gifpath" or die "open $gifpath: $!\n";
- binmode IN;
- my @data;
- local $_ = '';
- while (read(IN, $_, 1024)) {
- push @data, $_;
- }
- close IN;
-
- ### Direct path:
- if (1) {
- my $path = $gifpath;
- $msg->attach(Subject => "Read path directly",
- Path => $path,
- Type => 'image/gif');
- }
-
- ### Cat (Unix only):
- if (1) {
- my $path = "cat $gifpath |";
- $msg->attach(Subject => "Cat path to pipe, and read that",
- Path => $path,
- Type => 'image/gif');
- }
-
- ### Array:
- if (1) {
- $msg->attach(Subject => "Read data as array",
- Data => \@data,
- Type => 'image/gif');
- }
-
- ### String:
- if (1) {
- $msg->attach(Subject => "Read data as string",
- Data => join('', @data),
- Type => 'image/gif');
- }
-
- ### Output:
- $msg->print(\*STDOUT);
-}
-exit(&main ? 0 : -1);
-1;
-__END__
-
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+mime_gif - encode a single gif by reading data different ways
+
+
+=head1 SYNOPSIS
+
+Usage:
+
+ mime_gif /path/to/some.gif
+
+
+=head1 DESCRIPTION
+
+Encode a multipart message where each part contains the same GIF
+file, but where the GIF file has been read-in in different ways.
+The subject line of each part will tell you how the GIF was read.
+
+
+=head1 AUTHOR
+
+Eryq, eryq@zeegee.com
+
+=cut
+
+use strict;
+use MIME::Lite;
+use Getopt::Std;
+
+#------------------------------
+# main
+#------------------------------
+sub main {
+ my %opts;
+
+ ### Get options:
+ getopts('', \%opts) or die "usage error\n";
+ my $gifpath = $ARGV[0] || die "missing path to GIF\n";
+
+ ### Create message:
+ my $msg = MIME::Lite->new(To => 'me@somewhere.com',
+ Subject => 'GIF test',
+ Type => 'multipart/mixed');
+
+ ### Read data:
+ open IN, "<$gifpath" or die "open $gifpath: $!\n";
+ binmode IN;
+ my @data;
+ local $_ = '';
+ while (read(IN, $_, 1024)) {
+ push @data, $_;
+ }
+ close IN;
+
+ ### Direct path:
+ if (1) {
+ my $path = $gifpath;
+ $msg->attach(Subject => "Read path directly",
+ Path => $path,
+ Type => 'image/gif');
+ }
+
+ ### Cat (Unix only):
+ if (1) {
+ my $path = "cat $gifpath |";
+ $msg->attach(Subject => "Cat path to pipe, and read that",
+ Path => $path,
+ Type => 'image/gif');
+ }
+
+ ### Array:
+ if (1) {
+ $msg->attach(Subject => "Read data as array",
+ Data => \@data,
+ Type => 'image/gif');
+ }
+
+ ### String:
+ if (1) {
+ $msg->attach(Subject => "Read data as string",
+ Data => join('', @data),
+ Type => 'image/gif');
+ }
+
+ ### Output:
+ $msg->print(\*STDOUT);
+}
+exit(&main ? 0 : -1);
+1;
+__END__
+
View
116 examples/mime_hack
@@ -1,58 +1,58 @@
-#!/usr/bin/perl -w
-
-
-=head1 NAME
-
-mime_hack - test the "attach to singlepart" hack
-
-
-=head1 SYNOPSIS
-
-Usage:
-
- mime_hack /path/to/some.gif
-
-
-=head1 DESCRIPTION
-
-Encode a multipart message by starting with a text message,
-and attaching a GIF file to it.
-
-
-=head1 AUTHOR
-
-Eryq, eryq@zeegee.com
-
-=cut
-
-use strict;
-use MIME::Lite;
-use Getopt::Std;
-
-#------------------------------
-# main
-#------------------------------
-sub main {
- my %opts;
- my $gif = $ARGV[0] || die "usage error: missing GIF path\n";
-
- ### Create a new multipart message:
- my $msg = MIME::Lite->new(From => 'me@myhost.com',
- To => 'you@yourhost.com',
- Subject =>'Test the "attach to singlepart" hack',
- Type => 'TEXT',
- Data => ["This is a simple text message... ",
- "can we attach a file to it?\n"]);
-
- ### Attach a part:
- $msg->attach(Type => 'image/gif',
- Path => $gif);
-
- ### Output!
- $msg->print;
-}
-exit (&main ? 0 : -1);
-
-__END__
-
-
+#!/usr/bin/perl -w
+
+
+=head1 NAME
+
+mime_hack - test the "attach to singlepart" hack
+
+
+=head1 SYNOPSIS
+
+Usage:
+
+ mime_hack /path/to/some.gif
+
+
+=head1 DESCRIPTION
+
+Encode a multipart message by starting with a text message,
+and attaching a GIF file to it.
+
+
+=head1 AUTHOR
+
+Eryq, eryq@zeegee.com
+
+=cut
+
+use strict;
+use MIME::Lite;
+use Getopt::Std;
+
+#------------------------------
+# main
+#------------------------------
+sub main {
+ my %opts;
+ my $gif = $ARGV[0] || die "usage error: missing GIF path\n";
+
+ ### Create a new multipart message:
+ my $msg = MIME::Lite->new(From => 'me@myhost.com',
+ To => 'you@yourhost.com',
+ Subject =>'Test the "attach to singlepart" hack',
+ Type => 'TEXT',
+ Data => ["This is a simple text message... ",
+ "can we attach a file to it?\n"]);
+
+ ### Attach a part:
+ $msg->attach(Type => 'image/gif',
+ Path => $gif);
+
+ ### Output!
+ $msg->print;
+}
+exit (&main ? 0 : -1);
+
+__END__
+
+
View
184 examples/mime_longlines
@@ -1,92 +1,92 @@
-#!/usr/bin/perl -w
-
-
-=head1 NAME
-
-mime_longlines - generate a test message with long lines
-
-
-=head1 SYNOPSIS
-
-Usage:
-
- mime_longlines [-s]
-
-Options:
-
- -s Stringify message first, and print the *string* to STDOUT.
-
-
-=head1 DESCRIPTION
-
-Assemble and print (to the standard output) a multipart message
-with 5 attachments, for the purpose of "eyeballing" how well the
-encoders are working.
-
-Each attachments holds the same data -- some 8-bit text, and a long
-line consisting of 1000 "a"s followed by a few "b"s) -- but each
-has a different encoding (the "Content-transfer-encoding" field
-will tell you which is which).
-
-All of the encodings (except for the first one, "binary") should
-break the long line before the b's.
-
-
-=head1 AUTHOR
-
-Eryq, eryq@zeegee.com
-
-=cut
-
-use strict;
-use MIME::Lite;
-use Getopt::Std;
-
-### Set up a long message:
-my $DATA = <<EOF;
-Here's a line with some 8-bit characters... the "7bit" encoding should
-strip them out:
-
- \xABFran\xE7ois M\xFCller\xBB.
-
-The line below is REALLY long. It contains 1000 a's, followed by some b's.
-All of the encodings (except binary) should break the line before the b's:
-
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbb
-
-EOF
-
-#------------------------------
-# main
-#------------------------------
-sub main {
- my %opts;
-
- ### Get options:
- getopts('s', \%opts) or die "usage error\n";
-
- ### Create a new multipart message:
- my $msg = new MIME::Lite
- From =>'me@myhost.com',
- To =>'you@yourhost.com',
- Cc =>'some@other.com, some@more.com',
- Subject =>'The Magnificent Five (encodings, that is)',
- Type =>'multipart/mixed';
-
- ### Add parts:
- foreach my $enc (qw(binary 8bit 7bit quoted-printable base64)) {
- $msg->attach(Type => 'TEXT',
- Data => $DATA,
- Encoding => $enc);
- }
-
- ### Print:
- if ($opts{'s'}) { print $msg->stringify }
- else { $msg->print(\*STDOUT) }
- 1;
-}
-exit (&main ? 0 : -1);
-1;
-
-__END__
-
+#!/usr/bin/perl -w
+
+
+=head1 NAME
+
+mime_longlines - generate a test message with long lines
+
+
+=head1 SYNOPSIS
+
+Usage:
+
+ mime_longlines [-s]
+
+Options:
+
+ -s Stringify message first, and print the *string* to STDOUT.
+
+
+=head1 DESCRIPTION
+