MailTools-2.13/0000755000175000001440000000000012262315741014063 5ustar00markovusers00000000000000MailTools-2.13/META.yml0000644000175000001440000000110112262315741015325 0ustar00markovusers00000000000000--- abstract: 'Various e-mail related modules' author: - 'Mark Overmeer ' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120630' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: MailTools no_index: directory: - t - inc requires: Date::Format: 0 Date::Parse: 0 IO::Handle: 0 Net::Domain: 1.05 Net::SMTP: 1.03 Test::More: 0 version: 2.13 MailTools-2.13/examples/0000755000175000001440000000000012262315740015700 5ustar00markovusers00000000000000MailTools-2.13/examples/send_demo.PL0000644000175000001440000000360112262315737020100 0ustar00markovusers00000000000000# This -*- perl -*- script makes the send_demo script # $Id: send_demo.PL,v 1.2 1997/01/16 20:43:35 gbarr Exp $ $script = "./send_demo"; use Config; use Cwd; unlink($script); $cwd = Cwd::getcwd(); open MIR, ">$script" or die "open for writing $script: $!"; print MIR $Config{'startperl'}," -w\n"; #print MIR "use lib qw($cwd/blib);\n"; print MIR ; chmod(0755, $script); __DATA__ require Mail::Internet; require Mail::Alias; use Getopt::Long; sub expand_aliases { my $mail = shift; my $aliasfile = $ENV{HOME} . "/.mailrc"; my($tag,$id); if( -f $aliasfile ) { my $alias = Mail::Alias::Binmail->new($aliasfile); # Expand aliases foreach $tag (qw(To Cc Bcc)) { @ids = (); foreach $id (Mail::Address->parse($mail->get($tag))) { my $addr = $id->address; my @expn = $alias->expand($addr); if(scalar(@expn) == 1) { $id->address($expn[0]); push(@ids,$id->format); } else { push(@ids,@expn); } } $mail->combine($tag,','); $mail->replace($tag, join(", ", @ids)); } } } ### ### Main program ### GetOptions(qw(post nosig v)); $opt_post = 1 if $0 =~ m#(\A|/)post\Z#; $verbose = defined $opt_v && $opt_v ? 1 : 0; $posting = defined $opt_post && $opt_post ? 1 : 0; $sign = defined $opt_nosig && $opt_nosig ? 0 : 1; $mail = Mail::Internet->new([ <> ]); expand_aliases($mail); $mail->add_signature if($sign); if($posting) { my @groups = $mail->nntppost(); if($verbose && @groups) { $groups = "Newsgroups: " . join(", ", @groups); $groups =~ s/(.{10,78}),/$1\n/g if(length($groups) > 78); print $groups,"\n"; } } else { $mail->delete('Newsgroups'); } @recp = $mail->smtpsend(); if($verbose && @recp) { $recp = "Recipients: " . join(", ", @recp); $recp =~ s/(.{10,78}),/$1\n/g if(length($recp) > 78); print $recp,"\n"; } exit; MailTools-2.13/examples/mail-mailer.pl0000644000175000001440000000624112262315737020437 0ustar00markovusers00000000000000#!/usr/bin/perl -w # Note by Mark Overmeer: # This script does work, but Mail::Send may provide a nicer interface # NAME # mail-mailer.pl - Smtp client written in Perl # # SYNOPSIS # mail-mailer.pl -s "Test" --smtp=my-smtp-server.com admin@net1.net # # INTRODUCTION # This script can be an alternative to the 'mail' Unix command when # sending e-mails. # It reads the mail body from the standard input. # If your system is Windows, use the '--smtp' option to send your # e-mails. # This script works in Linux, Unix and Windows environments. # # OPTIONS # -f From # -s Subject # -c Cc-address # -b bcc-address # --sendmail Use sendmail to send the e-mail # --qmail Use qmail-inject to send the e-mail # --smtp=HOSTNAME Use HOSTNAME as the SMTP server. # --help Prints the help info and exits # # EXAMPLES # cat mailbody.txt | mail-mailer.pl -f me@mydom.com -s "Hy dude" --sendmail friend@dom.com # # AUTHOR # Bruno Negrao G Zica # # COPYRIGHT # Copyright (c) 2004 Bruno Negrao G Zica. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. # # LAST MODIFIED # 01/12/2004 ################################################################## use Mail::Mailer; use Getopt::Long; use strict; # hash that'll receive the arguments and options my %opt; GetOptions ( \%opt, 'help', 'f=s', 's=s', 'c=s', 'b=s', 'sendmail', 'qmail', 'smtp=s' ); if ($opt{help}) { help(); exit 0; } $opt{to} = $ARGV[$#ARGV]; # the "To" address is the last argument die "Error: You didn't specify a destination e-mail address.\n" unless ( $opt{to} || $opt{c} || $opt{b} ); # Defining the method to send the message my $mailer; # Mail::Mailer object if ($opt{sendmail}) { $mailer = new Mail::Mailer 'sendmail'; } elsif ($opt{qmail}) { $mailer = new Mail::Mailer 'qmail'; } elsif ($opt{smtp}) { $mailer = new Mail::Mailer 'smtp', Server => $opt{smtp}; } else { die "Error: you didn't specify the delivery method. ". "Possible methods are:\n'--qmail', '--sendmail', and ". "--smtp=HOSTNAME\n"; } # Setting the headers my %headers; # hash with the e-mail headers $headers{To} = $opt{to}; $headers{From} = $opt{f} if defined $opt{f}; $headers{Cc} = $opt{c} if defined $opt{c}; $headers{Bcc} = $opt{b} if defined $opt{b}; $headers{Subject} = $opt{s} if defined $opt{s}; $mailer->open(\%headers); # Reading and feeding the e-mail body while () { last if ( $_ =~ /^\.$/ ); print $mailer $_; } # Finishing $mailer->close(); # Subroutines sub help { print ' Example 1: Entering the e-mail body by hand: mail-mailer.pl -s "Hy buddy" --qmail friend@domain.com [ ENTER YOU MESSAGE BODY ] [ A SINGLE . (dot sign) ALONE IN ONE LINE TO SAY ] [ YOU FINISHED YOUR E-MAIL ] . Example 2: Using the output of another program as the body: dir c:\ | perl mail-mailer.pl -f me@mydom.com -s "My c:\" admin@mydom.com --smtp=server1.mydom.com OPTIONS -f addr From address. -s TEXT Subject. -c addr Cc-address. -b addr bcc-address. --sendmail Use sendmail to send the e-mail. --qmail Use qmail-inject to send the e-mail. --smtp HOSTNAME Use HOSTNAME as the SMTP server. --help Prints this help text. '; } MailTools-2.13/examples/rplyto_demo.PL0000644000175000001440000000142712262315737020504 0ustar00markovusers00000000000000# This -*- perl -*- script makes the rplyto_demo script # $Id: rplyto_demo.PL,v 1.2 1997/01/16 20:43:35 gbarr Exp $ $script = "./rplyto_demo"; use Config; use Cwd; unlink($script); open MIR, ">$script" or die "open for writing $script: $!"; print MIR $Config{'startperl'}," -w\n"; $cwd = Cwd::getcwd(); #print MIR "use lib qw($cwd/blib);\n"; print MIR ; chmod(0755, $script); __DATA__ use Mail::Internet; $mail = Mail::Internet->new([<>]); $rply = $mail->reply(Keep => [qw(Newsgroups)]); $file = "/tmp/reply.$$"; open(REPLY,">$file") || die "Cannot open $file:$!\n"; $rply->print(\*REPLY); close(REPLY); $editor = $ENV{"EDITOR"} || die "\$EDITOR not defined\n"; warn "$editor :$!\n" if (system("$editor $file")); # Cleanup unlink($file,$file . '%',$file . '~'); exit 0; MailTools-2.13/examples/forwd_demo.PL0000644000175000001440000000222312262315737020267 0ustar00markovusers00000000000000# This -*- perl -*- script makes the forwd_demo script # $Id: forwd_demo.PL,v 1.2 1997/01/16 20:43:34 gbarr Exp $ use Config; use Cwd; $script = "./forwd_demo"; unlink($script); open MIR, ">$script" or die "open for writing $script: $!"; print MIR $Config{'startperl'}," -w\n"; $cwd = Cwd::getcwd(); #print MIR "use lib qw($cwd/blib);\n"; print MIR ; chmod(0755, $script); __DATA__ use Mail::Internet; @mail = <>; $mail = Mail::Internet->new(\@mail); $mail->remove_sig; $mail->tidy_body; @reply = (); if(open(HDR,"$ENV{HOME}/.mailhdr")) { @reply = ; close(HDR); } $rply = Mail::Internet->new(\@reply); $subject = $mail->get('Subject'); $rply->replace('To', ""); $rply->replace('Cc', ""); $rply->replace('Subject',$subject); $rply->body($body = $mail->body); unshift @{$body},"---------- Begin Included Message ----------\n"; push @{$body},"----------- End Included Message -----------\n"; $file = "/tmp/reply.$$"; open(FILE,">$file") || die "Cannot open $file:$!\n"; $rply->print(\*FILE); close(FILE); $editor = $ENV{"EDITOR"} || "/usr/bin/nvi"; warn "$editor :$!\n" if (system("$editor $file")); unlink($file,$file . '%'); exit 0; MailTools-2.13/xt/0000755000175000001440000000000012262315740014515 5ustar00markovusers00000000000000MailTools-2.13/xt/99pod.t0000644000175000001440000000011712262315737015653 0ustar00markovusers00000000000000#!/usr/bin/perl use warnings; use strict; use Test::Pod; all_pod_files_ok(); MailTools-2.13/Makefile.PL0000644000175000001440000000160412262315737016043 0ustar00markovusers00000000000000require 5.008001; use ExtUtils::MakeMaker; WriteMakefile ( DISTNAME => 'MailTools' , VERSION => '2.13' , NAME => 'Mail' , AUTHOR => 'Mark Overmeer ' , ABSTRACT => 'Various e-mail related modules' , LICENSE => 'perl' , PREREQ_PM => { Net::SMTP => 1.03 , Net::Domain => 1.05 , IO::Handle => 0.00 , Test::More => 0.00 , Date::Format => 0 , Date::Parse => 0 # next deps missing on purpose, to avoid installing a lot which # is rarely used. # Authen::SASL # Net::SMTP::SSL } ); sub MY::postamble { return '' unless $] >= 5.00503; <<'ESQ'; all:: ppd dist: ppd # for OODoc's oodist, DIST RAWDIR = ../public_html/mailtools/raw DISTDIR = ../public_html/mailtools/source LICENSE = artistic # for OODoc's oodist, POD FIRST_YEAR = 1995 EMAIL = perl@overmeer.net WEBSITE = http://perl.overmeer.net/log-report/ ESQ } MailTools-2.13/README0000644000175000001440000000130412262315737014746 0ustar00markovusers00000000000000 === README for MailTools MailTools is a set of Perl modules related to mail applications. These modules are very old (partially written before MIME!). If you start to write a new e-mail application, consider to use MailBox instead (http://perl.overmeer.net/mailbox/) It is a little harder to learn, but at least implements all RFCs correctly. You require perl 5.8.1 or later to use this library. When your Perl is older, then use version 1.xx. You install the library by running these commands: perl Makefile.PL make make test make install There are also some demo scripts (see README.demos) Please report any bugs/suggestions to http://rt.cpan.org/Dist/Display.html?Queue=MailTools MailTools-2.13/MailTools.ppd0000644000175000001440000000106612262315737016503 0ustar00markovusers00000000000000 Various e-mail related modules Mark Overmeer <perl@overmeer.net> MailTools-2.13/ChangeLog0000644000175000001440000007335212262315737015654 0ustar00markovusers00000000000000 ==== version history for MailTools version 2.13: Sun Jan 5 18:52:25 CET 2014 Fixes: - optional 'from' and 'on' component in in-reply-to are comments rt.cpan.org#89371 [Ward Vandewege] - mailcap \\\\ -> \\ rt.cpan.org#89802 [Kevin Ryde] Improvements: - fix typos rt.cpan.org#87188 [D Steinbrunner] version 2.12: Fri Dec 21 12:18:51 CET 2012 Fixes: - default for Mail::Header::new(Modify) is 'false', not 'true' rt.cpan.org#79985 [Thomas Sibley] - Mail::Address take username with rindex(), a bit better than index() but still poor. rt.cpan.org#82056 [Filipe Gonçalves] Improvements: - check for bad folding of header lines rt.cpan.org#79993 [Thomas Sibley] - add a note about better to avoid Mail::Address->name(), in response to a question by rt.cpan.org#81459 [Moritz Lenz] version 2.11: Wed Aug 29 09:09:47 CEST 2012 Fixes: - typo in Mail::Mailer::smtp, which only shows up in >5.14 [cpantesters] version 2.10: Tue Aug 28 09:41:52 CEST 2012 Fixes: - Mail::Mailer::smtp set from address twice. rt.cpan.org#77161 [Vladimir Goshev] - Mail::Mailer::smtps did not support the From option. rt.cpan.org#77161 [Vladimir Goshev] Improvements: - Mail::Util::mailaddress has now an optional parameter to set the returned value explicitly. rt.cpan.org#75975 [Rolf G] version 2.09: Sat Feb 25 14:47:39 CET 2012 Improvements: - remove dependency to Test::Pod by moving 99pod.t from t/ to xt/ as result of rt.cpan.org#69918 [Martin Mokrejs] version 2.08: Wed Jun 1 13:55:34 CEST 2011 Fixes: - respect errors on closing an Mail::Mailer::smtp/::smtps connection. [Tristam Fenton-May] - Mail::Internet should accept Net::SMTP::SSL as well. rt.cpan.org#68590 [Jonathan Kamens] Improvements: - document that Mail::Mailer::smtps needs Authen::SASL [Marcin WMP Janowski] version 2.07: Fri Oct 1 12:39:43 CEST 2010 Improvements: - update README: MailTools 2.* require 5.8.1 rt.cpan.org#61753 [Alexandre Bouillot] - add "MAIL FROM" to Mail::Mailer::smtp, to be able to communicate with Comcast [David Myers] version 2.06: Tue Jan 26 10:01:22 CET 2010 Improvements: - express more clearly that Authen::SASL needs to be installed manually if you need the functionality - support for smtps via Net::SMTP::SSL, by [Maciej Żenczykowski] version 2.05: Fri Dec 18 22:39:21 CET 2009 Fixes: - no de-ref error when index out of range in Mail::Header::get() [Bob Rogers] - repaired fixed selection of smtp for non-unix systems. Improvements: - do not run pod.t in devel environment. - set default output filename for Mail::Mailer::testfile::PRINT [Kaare Rasmussen[ - warn when no mailers were found. rt.cpan.org#52901 [Christoph Zimmermann] version 2.04: Tue Jul 29 11:44:26 CEST 2008 Fixes: - Mail::Field::_require_dir complained on 5.10 about a closed dirhandle. rt.cpan.org#37114 [Manuel Hecht] - Bcc line removed before collecting addresses. [Jørgen Thomsen] Improvements: - add "die" to "close()" in synopsis of Mail::Send and Mail::Mailer. rt.cpan.org#36103 [Ed Avis] version 2.03: Mon Apr 14 11:13:31 CEST 2008 Fixes: - Netware needs to use smtp as well [Günter Knauf] - Mail::Field::extract() fixed. Reported by [Andrea Venturol] version 2.02: Fri Nov 30 09:57:48 CET 2007 Fixes: - Mail::Internet uses Mail::Util::mailaddress, which is not exported by default. rt.cpan.org#31082 [Dave], rt.cpan.org#31070 [Friedrich Haubensak] and [Slaven Rezic] Improvements: - use 3-arg open() in Mail::Util. rt.cpan.org#20726 [Steve@sliug] and [Paul@city-fan] version 2.01: Wed Nov 28 10:48:24 CET 2007 Changes: - Remove work-around for Perl 5.8.0. unicode bug from Mail::Address::_extract_name(). Result of rt.cpan.org#30661 [Josh Clark] - Requires on Perl 5.8.1 minimum Fixes: - Mail::Mailer::testfile now also shows Cc destinations, the setting of 'outfile' now works, and it will produce an error when the data cannot be written. All thanks to [Slaven Rezic] version 2.00_03: Tue Sep 25 12:27:28 CEST 2007 - folding of header fields sometimes ended prematurely. Reported by [Anthony W. Kay] - add $sender as 4th argument to Mail::Mailer::*::exec() where missing. Discovered by [David Hand] - add Date::Format and Date::Parse to Makefile.PL. version 2.00_02: Sat Jul 21 12:29:20 CEST 2007 - parts of the documentation were lost, discovered by [Ricardo Signes] - rt.cpan.org #28093 smtp timeout check for local mail server can have short timeout. Patch by [Alexandr Ciornii] - rt.cpan.org #28411 syntax error in Mail::Mailer::smtp reported by [Andreas Koenig] version 2.00_01: Wed Jun 20 14:42:35 CEST 2007 - reorganized installation of MailTools, in a modern way. This may break installation on very old releases of Perl. - added t/pod.t - restructured most code, no functional changes. - added and cleaned a lot of documentation, using OODoc to generate nice manuals in POD and HTML. - extracted Mail::Field::Generic from Mail::Field - added misteriously missing Mail::Field::AddrList::addr_list() version 1.77: Fri May 11 14:16:01 CEST 2007 - fixed syntax error in qmail.pm, patch by [Alexey Tourbin] also reported by [Volker Paulsen] - die if qmail's exec fails. - require Data::Format - corrected header field folding according to rfc2822, which may break some ancient (poor) applications. Patch by [Christopher Madsen] version 1.76: Tue Apr 10 09:25:29 CEST 2007 - The tag (field label) casing is "normalized" which is not required (as the comment in the code told), but a mis- feature. The feature will not change, to avoid breaking existing code. Original report by [Matt Swift] - Do not ignore unknown argument to Mail::Internet::new(), but complain about it [JPBS] - Document that the \n is still after a header line, but folding is removed. Suggested by [Roberto Jimenoca] - Document that unfolding is too greading, taking all leading blanks where only one should be taken. Suggested by [Roberto Jimenoca] version 1.75: Wed Jun 14 15:30:25 CEST 2006 - [Mike Lerley] reported that environment variables are not thread-safe in mod_perl. Therefore, we must pass the sender of the message explictly on qmail's command-line. His addapted patch included. version 1.74: Tue Feb 28 08:39:14 CET 2006 - Finally fixed exec with SMTP, with help from [Jun Kuriyama] version 1.73: Sat Jan 21 09:54:13 CET 2006 - Added 'use Mail::Util' to Mail::Mailer::testfile to produce mailaddress(); - Improved exec() call from version 1.67 a little more. Let's hope that SMTP works again. version 1.72: Tue Jan 17 09:04:37 CET 2006 - release 1.70 broke SMTP sending. Detected by [J Meyers] version 1.71: Thu Jan 5 11:20:52 CET 2006 - grrrr tests failed version 1.70: Thu Jan 5 11:17:05 CET 2006 - Mail::Mailer::testfile.pm adds "from" display to trace output. [wurblzap] - fixed regex in Mail::Address [J Meyers] version 1.68: Thu Jan 5 10:29:25 CET 2006 - Updated copyright year. - Removed 'use locale' from Mail::Address, which tainted the parsed address. E-mail addresses are ASCII, so this 'locale' thing seems flawed. - $adr->name will refuse charset-encoded names. Found by [kappa] - Improve parse-regexes in Mail::Address. By [J Meyers] and me. version 1.67: Thu Mar 31 12:05:31 CEST 2005 - Mail::Mailer unfolded the header before sending, which is incorrect. Reported by [Byron Jones] - Mail::Header refolded already folded lines destroying blanks. Signaled by [Byron Jones] - Mail::Utils::maildomain now understands DM$m. Patch by [Nate Mueller] - When a Mail::Mailer exec() failes, DESTROY is called on all parential files. Not anymore thanks to [Randall Lucas] version 1.66: Thu Jan 20 10:16:10 CET 2005 - Extended explanation that Mail::Address is limited. - Added examples/mail-mailer.pl, contributed by [Bruno Negrão] - use Mail::Mailer qw(mail) sets default mailer. Doc update by [Slavan Rezic] - Mail::Mailer::smtp now can authenticate SSL [Aaron J. Mackey] version 1.65: Wed Nov 24 15:43:17 CET 2004 - Remove "minimal" comments from Mail::Address - [Dan Grillo] suggested some improvements to Mail::Address::name(), and some more were added. - [Slavan Rezic] small typo. version 1.64: Tue Aug 17 22:24:22 CEST 2004 - CPAN failed to index 1.63 correctly, so hopefully it will work now. version 1.63: Mon Aug 16 17:28:15 CEST 2004 - [Craig Davison] Fixed date format in Mail::Field::Date to comply to the RFC - [Alex Vandiver] patched the email address parser to be able to understand a list of addresses separated by ';', as Outlook does. The ';' is the group separator, which was not understood by MailTools before, but valid according to the RFCs. - [Torsten Luettgert] found that field labels like '-' where not beautified correctly. - [Slavan Rezic] Updated doc in Mail::Mailer: referred to $command which doesn't mean anything, and "testfile" is working differently. - [chris] Mail::Message::Field::wellformedName() will upper-case *-ID as part in the fieldname. version 1.62: Wed Mar 24 13:29:27 CET 2004 - [Reuven M. Lerner], removed warning by Mail::Address::host() when no e-mail address is provided. - [Ville Skytta] contributed another Mail::Mailer::testfile fix version 1.61: Wed Mar 10 10:51:44 CET 2004 - [Erik Van Roode] Mail::Mailer::test.pm -> Mail::Mailer::testfile.pm - [Jérôme Dion] corrected the folding of lines: folds start only with one blank according to rfc2822. - Added a big warning against automatic sender email address detection as provided by Mail::Util::mailaddress(). Please explicitly set MAILADDRESS. This after a discussion with [Wolfgang Friebel]. - Mail::Address->format should quote phrases with weird character. Patched based on patch by [Marc 'HE' Brockschmidt] - [Ruslan U. Zakirov] reported confusing error message when no MailerType was specified. - [Steve Roberts] fixed folding to produce longer lines. version 1.60: Wed Sep 24 09:20:30 CEST 2003 - [Henrique Martins] found that enclosing parenthesis where not correctly stripped when processing a Mail::Address. - [Tony Bowden] asked for a change in Mail::Address::name, where existing (probably correct) capitization is left intact. The _extract_name() can be called as method, is needed, such that it can be extended. version 1.59: Wed Aug 13 08:13:00 CEST 2003 - Patch by [Shafiek Rasdien] which adds Mail::Internet::smtpsend option MailFrom. - [Ziya Suzen] extended Mail::Mailer::test to provide more test information. - Added SWE (Sender Waranted E-mail) as abbreviation in field names which is always in caps, on request by [Ronnie Paskin] - Added SOAP and LDAP as abbreviation in field names which is always in caps. version 1.58: Tue Jan 14 14:42:29 CET 2003 - And again utf8 [Philip Molter] version 1.57: Tue Jan 14 09:47:46 CET 2003 - Added myself to the copyright notices... dates needed an update as well. - Typos in Mail::Internet [Florian Helmberger] - More tries to program around perl5.8.0's uc/lc-utf8 bugs in regexps [Autrijus Tang and Philip Molter] version 1.56: Mon Jan 6 17:13:17 CET 2003 - And again, the patches of Autrijus had to be adapted to run on a perl 5.6.1 installation. Thanks to [Philip Molter] version 1.55: Mon Jan 6 08:05:58 CET 2003 - One explicit utf8::downgrade for 5.8.0, this time for Mail::Address by [Autrijus Tang]. version 1.54: Mon Jan 6 08:00:00 CET 2003 - Another try to avoid the utf8 problems, this time by [Philip Molter] - Two explicit utf8::downgrades for 5.8.0, this time for Mail::Field by [Autrijus Tang]. version 1.53: Mon Dec 9 17:53:27 CET 2002 - New try on work-around for bug in perl 5.8.0 unicode \U within s/// Patched in Mail::Header by [Autrijus Tang] version 1.52: Fri Nov 29 13:52:00 CET 2002 - Work-around for bug in perl 5.8.0 unicode \U within s/// Patched in Mail::Header by [Autrijus Tang] version 1.51: Tue Oct 29 14:25:28 CET 2002 - Mail::Util::maildomain() if no information about domains is found in sendmail.cf, no error should be reported. [Vaughn Skinner] - Removed the possibility to use 'mailx', which was the default: removal from the detectionn routines and Mail/Mailer/mail.pm. Strongly suggested by [Sebastian Krahmer] version 1.50: Wed Sep 4 00:38:49 CEST 2002 - Mail::Util::domainname() Patch to remove use of S variable from sendmail.cf, because its inclusion is contra-productive. [Timur Bakeyev] - Mail::Util::domainname() Clean domain from sendmail.cf from trailing trash (if present) [Timur Bakeyev] - Mail::Util::domainname() Added environment variable MAILDOMAIN to overrule smart domain discovery. [Timur Bakeyev] version 1.49: Wed Aug 28 08:36:58 CEST 2002 - t/internet.t defaults $ENV{LOGNAME} to avoid warnings in tests when that variable is not defined. [Chromatic] - Mail::Mailer::_clean_up left an extra space behind each header line. Patched by [Robert Spier] - Mail::Mailer::_clean_up now also trims folded headerlines on more than two lines. version 1.48: Wed Aug 7 22:54:56 CEST 2002 - Mail::Mailer::test only worked in UNIX, because it used the 'test', 'sh' and 'cat' command. [Matt Selsky] provided a patch to remove these dependencies. It may not work on ancient perl versions, but that is not really a problem for a testing facility. - The fix for nested comments in Mail::Address's, which went in a long time ago, broke the parser. As example "Mark Overmeer (mailtools maintainer)" was parsed into two separate objects.... wrong. [Nicholas Oxhøj] reversed the patch. version 1.47: Fri Jul 5 12:02:55 CEST 2002 - Mail::Mailer::_cleanup_headers unfolds the header lines, but forgot to remove the indentation blanks as was discovered by [Meng Weng Wong] - Mail::Cap::new has two new options: filename => FILENAME, which is just long for FILENAME only take => 'ALL', to include all mail-cap files, not only the first one found. Contributed by [Oleg Muravskiy] version 1.46: Wed May 29 15:08:44 CEST 2002 - [Philip Molter] discoverd my typo in Mail/Mailer/rfc822.pm which forced me to release a new version.... version 1.45: Thu May 23 10:15:59 CEST 2002 - [Mark D. Anderson] Add Content-Disposition to the list of structured header fields in Mail::Header. - [David Weeler] Added darwin to `mail' versions which require '-I' in Mail::Mailer. - [Leon Avery] updated Mail/Mailer/rfc822.pm to be more careful with multi-lined, multi-occurence headers. - [Drieux] small fix in Mail/Mailer/smtp.pm which enables the passing-on of args to Net::SMTP. - {Mark Overmeer] Put a message about Mail::Box in Mail::Internet version 1.44 Sat Mar 23 10:16:47 CET 2002 - [Andreas Marcel Riechert] add -I to mailx for netbsd and openbsd too. - [Nate Mueller] Do respect user's X-Mailer in Mail::Internet above own line. - [Alexey Egorov] Header-line without body lost line-separator in Mail::Header.pm - [Bo Adler] and [Iosif Fettich] Found that I removed a blank before 'sub smtpsend' which caused AutoSplit to misbehave. version 1.43: Fri Feb 8 09:43:25 CET 2002 - [Jason Burnett] Added debug option for Net::SMTP for Mail::Mail::smtp. - [Slavan Rezic] + [Jonathan Stowe] Added eval around getpwuid, to avoid croak on Windows. - [Slavan Rezic] minor doc update. The documentation is still poor. - A lot of people complaint (and that after so many years that the module is active) about folder lines within words or strings. The mistake in the original implementation was that it tried to fold too hard; folding is a service, but no requirement. So: that overly active folding is removed now. version 1.42: Mon Dec 10 19:22:01 CET 2001 - Moved examples from bin/ to examples/, so people may be able to find them. - Mail::Util now also tries sendmail option S for domainname. Patched by [Todd R. Eigenschink] Included Debian changes by [Steve Kowalik]: - Added Mail::Mailer::qmail version 1.41: Wed Nov 14 10:35:57 CET 2001 - Mail::Util::maildomain did not expand variables. Fixed the regular expression. Reported by [Jean-Damien Durand] - [Henrik Gemal] wished better warnings in Mail::Address::parse, which are provided now. - [Lucas Nussbaum] reported incorrect folding of unstructured header lines. The whole idea of folder unstructured fields is flawed, as far as I know, but anyway noone apparantly had sufficient long subject fields to find-out ;) Fixed in Mail::Mailer. version 1.40: Fri Aug 24 20:15:30 CEST 2001 - mailaddress defaults to username, not gcos in Mail/Util.pm Patched by [Vivek Khera] - Increased all version-numbers to show that maintainer-address did change. Suggested by [Tassilo v Parseval] All packages in this bundle with have the same version!!! The highest number used was 1.33. version 1.16: Wed Aug 8 11:28:26 CEST 2001 by Mark Overmeer From now on MailTools will be maintained by Mark Overmeer - Updated all manual-pages to include address of new maintainer. - Prohibition to modify header should be respected in Mail::Header. Patch by [Tatsuhiko Miyagawa] - Securely close socket in Mail::Mailer::smtp. Patch by [Heikki Korpela] - Fixed "bad file-descriptor" errors in Mail::Mailer::smtp. Patch by [Aaron J Mackey] - Some long header-lines caused the following line in the header to be indented too. This should be fixed. Reported by [Simon Cozens] - Small modifications to Mail::Mailer should make the module work for os2. Patch by [Ilya Zakharevich] - Fix to be able to specify an index at the first addition of a header-line to the Mail::Header structure. Patch by [Lucas Fisher] Change 583 on 2000/09/04 by (Graham Barr) Mail::Address - Remove some unneeded \'s in regex patterns (to keep 5.7.0 quiet) Change 582 on 2000/09/04 by (Graham Barr) Mail::Alias - Removed. Now distributed separatly and maintained by Tom Zeltwanger (ZELT) Change 581 on 2000/09/04 by (Graham Barr) Mail::Mailer - Remove newlines from the lines in the Mail::Header object Change 575 on 2000/08/24 by (Graham Barr) Mail::Mailer::mail - Fix problems with open(STDERR) when using under FCGI Change 571 on 2000/08/24 by (Graham Barr) Mail::Mailer - Deafulr Win32 to smtp Change 521 on 2000/05/16 by (Graham Barr) Mail::Internet - Added Debug and Port options to smtpsend Change 520 on 2000/05/16 by (Graham Barr) Mail::Header - Another fix for badly formed headers in _fold_line - get MIME right in _tag_case Change 519 on 2000/05/16 by (Graham Barr) t/mailcap.t - Do not assume user has perl in $PATH Change 502 on 2000/05/02 by (Graham Barr) Mail::Field - readdir returns files in the correct case, duh! Change 501 on 2000/04/30 by (Graham Barr) Mail::Header * Don't attempt to do a structured fold on non-structured header lines Change 498 on 2000/04/30 by (Graham Barr) Mail::Cap - Fix pod typo Change 490 on 2000/04/14 by (Graham Barr) Remove test in t/internet.t that sends an Email Change 457 on 2000/03/29 by (Graham Barr) Release 1.14 Change 456 on 2000/03/29 by (Graham Barr) Makefile.PL - Added PPD stuff Change 429 on 2000/03/28 by (Graham Barr) Makefile.PL changes Change 428 on 2000/03/28 by (Graham Barr) Mail::Mailer::sendmail - Remove @$to from command line as we pass -t Change 427 on 2000/03/28 by (Graham Barr) Mail::Send - to,cc and bcc should pass addresses as a list not as single string of , separated addresses Change 426 on 2000/03/28 by (Graham Barr) Mail::Mailer::smtp - override the close method from Mail::Mailer Change 425 on 2000/03/28 by (Graham Barr) Mail::Internet - _prephdr needed to use Mail::Util Change 424 on 2000/03/28 by (Graham Barr) Mail::Field - Generic packages do not have a file to require, so only require if !$pkg->can('stringify') Change 416 on 2000/03/28 by (Graham Barr) undef warning fix in Mail::Mailer::is_exe Change 415 on 2000/03/28 by (Graham Barr) Changes from (Tobias Brox) Mail::Internet - now have a send sub for sending emails Mail::Header - now have a header_hashref sub which allows modification of the object through hashrefs Change 360 on 2000/02/16 by (Graham Barr) Mail::Address - Fix for nested comments Change 350 on 2000/01/26 by (Graham Barr) Mail::Header - combine() should just return the line if there is only one Change 349 on 2000/01/26 by (Graham Barr) Mail::Header - Fix bug in fold_line for when a header line only contains a tag Change 335 on 1999/09/24 by (Graham Barr) Mail::Internet - Added Hello option to smtpsend() Change 292 on 1999/03/31 by (Graham Barr) Release 1.13 Change 291 on 1999/03/31 by (Graham Barr) Mail::Header - fold_line now skips X-Face lines Mail::Filter - Applied patch from (Josh Pincus) * Added return value to _filter() so that the function returns the result of the last subroutine in the list of filters. (the manpage specifies that one should have been able to do this originally.) Mail::Mailer - Treat VMS the same as MacOS as neither have sendmail et al. Mail::Mailer::smtp - Server can now be specified to Mail::Mailer contructor Mail::Alias, Mail::Util,Mail:Internet, Mail::Cap - local-ize some globals used Mail::Cap - check in $ENV{HOME} is defined Mail::Address - Fix capitalization problems with names like "Ließegang" Change 290 on 1999/03/31 by (Graham Barr) Increment version Change 213 on 1998/10/22 by (Graham Barr) Mail::Address - Fix use of uninitialized warning Change 190 on 1998/09/26 by (Graham Barr) Update Makefile.PL for release 1.12 Change 189 on 1998/09/26 by (Graham Barr) Mail::Internet - Added options to smtpsend Mail::Send - Updated docs for 'smtp' Change 188 on 1998/09/26 by (Graham Barr) Mail::Header - Fix _fold_line for lines which contain quoted strings Change 172 on 1998/07/10 by (Graham Barr) Mail::Address - avoid warnings if undef is passed to parse() Change 169 on 1998/07/04 by (Graham Barr) Mail::Address - tweak to format to ensure comment is delimeted by () - typo in docs Change 168 on 1998/07/04 by (Graham Barr) - Documentation update to Mail::Internet Change 166 on 1998/07/03 by (Graham Barr) Mail::Cap - Fixed mailcap search so it works on MacOS Change 165 on 1998/07/03 by (Graham Barr) Mail::Mailer - Change to use Mail::Util::mailaddress Mail::Util - updated mailaddess to be aware of MacOS Change 164 on 1998/06/30 by (Graham Barr) Mail::Header - fix read(0 and extract() not to require non-whitespace characters on continuation lines, a single leading whitespace char is all that is needed. Change 163 on 1998/06/30 by (Graham Barr) - Applied patch from Roderick Schertler to - Two places in Mail::Header are changed so they don't use $'. - A Mail::Header::as_string method is added. - Mail::Internet::as_string and as_mbox_string methods are added. The mbox variant does encoding appropriate for appending a message to a Unix mbox file. - Tests for the three new methods are added. Change 162 on 1998/06/30 by (Graham Barr) Mail::Util - tweak to what maildomain looks for in the sendmail config file Sun Jun 28 1998 (Graham Barr) Mail::Address - Split out real handlers into thier own .pm files - Added Mail::Mailer::smtp, this is the default for MacOS Wed Jun 17 1998 (Graham Barr) Mail::Mailer - Applied patch from Slaven Rezic to support FreeBSD properly Mail::Address - Applied patch from Chuck O'Donnell to improve name extraction t/extract.t - change for new extraction Sat Apr 4 1998 (Graham Barr) bin/*.PL - change "#!$Config{'scriptdir'}/perl -w\n" ot $Config{'startperl'}," -w\n" Thu Mar 19 1998 (Graham Barr) Mail::Field - modified so it works with perl < 5.004 Makefile.PL - removed code to prevent installation of Mail::Field Wed Feb 18 1998 (Graham Barr) Mail::Header - Added \Q and \E to some regexp's Tue Feb 17 1998 (Graham Barr) Mail::Mailer - Added patch from Jeff Slovin to pass correct args to mailx on DG/UX *** Release 1.11 Fri Jan 2 1998 (Graham Barr) Mail::Internet - Documentation updates Mail::Util - Fixed "Use of inherited AUTOLOAD" warning Mail::Mailer - Some version of mail do not like STDIN bot being a terminal and also print 'EOT' to stdout when done. Opened STDOUT/ERR to /dev/null Makefile.PL - Changed so that Mail::Field is not installed if perl version is less than 5.004 Mail::Mailer - removed all for(my $i ...) and foreach my $d as they break compatability with pre perl5.004 Tue Nov 25 1997 (Graham Barr) Mail::Mailer - Incremented VERSION, for some unknown reason it went backwards. Mon Nov 17 1997 (Graham Barr) Mail::Util - Added /var/adm/sendmail to the list of directories to search for sendmail.cf Mon Nov 17 1997 (Graham Barr) Mail::Internet - added options to nntppost Mail::Mailer.pm - Added check for bsdos to add -I option to Mail t/mailcap.t - MAde less unix specific by changing from using 'test' to using perl Sun Nov 16 1997 (Graham Barr) Added Mail::Field::AddrList to MANIFEST *** Release 1.10 Wed Nov 12 1997 (Graham Barr) Mail::Field::AddrList, Mail::Filter - new modules Mail::Field - Changes to the way sub-classes are registered and handled. Wed Nov 5 1997 (Graham Barr) Mail::Mailer - Modified code that searches for the executable to run --- --- -- 1997 (Graham Barr) Mail::Address - Documentation updates Mail::Header - Small tweak to _fold_line for lines that are just shorter than the fold width, but include whitespace Mail::Internet - does not inherit from AutoLoader. Instead AUTOLOAD is GLOB'd to AutoLoader::AUTOLOAD Mail::Mailer and Mail::Send - Modified PODs to reflect that Tim Bunce is not the maintainer. Mon Feb 24 1997 o Release 1.09 o Mail::Header Fixed a de-reference problem in unfold() _fold_line will no longer fold the From line that gets added by the user mail agent. o Mail::Internet Added DESTROY, to stop AutoLoader errors o Mail::Mailer Fixed an undef problem in new o Tests Added t/send.t and t/mailer.t Tue Jan 07 1996 o Release 1.08 o fixed Mail::Mailer::new so that it uses Symbol properly to generate the anonymous glob. Thu Jan 02 1996 Graham Barr o Release 1.07 o Removed Mail::MIME as it is now redundant. See $CPAN/authors/id/ERYQ/MIME-tools-x.xx for MIME related modules o Attempt to make Mail::Mailer find the correct mail program to invoke o Added Mail::Internet::unescape_from at the request of o Fixed a bug in _fmt_line, was appling a s/// to a ref ???, now de-ref o Added Mail::Internet::escape_from at the request of o Modified Mail::Internet::new so that it no longer accepts the message as an array. It now accepts an arg and key-value aoptions o Fixed a mis-spelling of Received in Internet.pm o Fixed a problem in Header.pm when return-ing line text and tag == 'From ' length($tag) + 2 is incorrect Wed Jul 24 1996 Graham Barr o Mail::Send, Mail::Mailer Incorporated a patch from Nathan Torkington to allow headers to be passed as scalars as well as list-refs. It also included some doc updates. Many thanks to Nathan Tue Nov 21 1995 Graham Barr o Added Mail::Internet::nntppost and Mail::Internet::smtpsend as AutoLoaded methods o Some small tweaks to mailaddress() Thu Nov 16 1995 Graham Barr o Modified Mail::Util to use Net::Domain Tue Nov 7 1995 Graham Barr o Changed name of Mail::RFC822 to Mail::Internet Wed Nov 1 1995 Graham Barr o Fixed remove_signature to be anchor'd to the start of the line o Re-vamped the reply to method Fri Sep 8 1995 Graham Barr o Applied patch from Andreas Koenig to fix problem when the user defined $\ Wed Aug 30 1995 Graham Barr o Updated documentation Tue Aug 29 1995 Graham Barr o Modified Mail::Util::maildomain to look in a list of places for sendmail.cf Thu Aug 24 1995 Graham Barr o Modified maildomain to look for /usr/lib/smail/config before attempting smtp Wed Aug 16 1995 Graham Barr o Modified maildomain to prepend hostname to domainname if it cannot find the address via SMTP o Added mailaddress() to Mail::Util Tue Aug 15 1995 Graham Barr o Modified Mail::Util::maildomain to parse /etc/sendmail.cf if it exists and extract the mail domain Mon Aug 14 1995 Graham Barr o Added maildomain into Mail::Util o Applied Andreas Koenig's patches to Mail::Mailer and Mail::Send Wed Jul 12 1995 Graham Barr o Added -a/-s switches to rplyto to enable a choice of reply to all or just the sender MailTools-2.13/lib/0000755000175000001440000000000012262315740014630 5ustar00markovusers00000000000000MailTools-2.13/lib/Mail/0000755000175000001440000000000012262315740015512 5ustar00markovusers00000000000000MailTools-2.13/lib/Mail/Internet.pod0000644000175000001440000002443012262315737020017 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Internet - manipulate email messages =head1 SYNOPSIS use Mail::Internet; my $msg = Mail::Internet->new(\*STDIN); =head1 DESCRIPTION This package implements reading, creating, manipulating, and writing email messages. Sometimes, the implementation tries to be too smart, but in the general case it works as expected. If you start writing a B, you should use the L distribution, which has more features and handles messages much better according to the RFCs. See L. You may also chose L, to get at least some multipart support in your application. =head1 METHODS =head2 Constructors =over 4 =item $obj-EB() Duplicate the message as a whole. Both header and body will be deep-copied: a new L object is returned. =item $obj-EB(ARRAY-of-LINES) Extract header and body from an ARRAY of message lines. Requires an object already created with L, which contents will get overwritten. =item $obj-EB([ARG], [OPTIONS]) =item Mail::Internet-EB([ARG], [OPTIONS]) ARG is optional and may be either a file descriptor (reference to a GLOB) or a reference to an array. If given the new object will be initialized with headers and body either from the array of read from the file descriptor. The L OPTIONS C, C and C may also be given. -Option--Default Body [] Header undef =over 2 =item Body => ARRAY-of-LINES The value of this option should be a reference to an array which contains the lines for the body of the message. Each line should be terminated with C<\n> (LF). If Body is given then C will not attempt to read the body from C (even if it is specified). =item Header => Mail::Header The value of this option should be a L object. If given then C will not attempt to read a mail header from C, if it was specified. =back =item $obj-EB(FILEHANDLE) Read a message from the FILEHANDLE into an already existing message object. Better use L with the FILEHANDLE as first argument. =back =head2 Accessors =over 4 =item $obj-EB([BODY]) Returns the body of the message. This is a reference to an array. Each entry in the array represents a single line in the message. If I is given, it can be a reference to an array or an array, then the body will be replaced. If a reference is passed, it is used directly and not copied, so any subsequent changes to the array will change the contents of the body. =item $obj-EB() Returns the C object which holds the headers for the current message =back =head2 Processing the message as a whole =over 4 =item $obj-EB([ALREADY_ESCAPED]) Returns the message as a string in mbox format. C, if given and true, indicates that L has already been called on this object. =item $obj-EB() Returns the message as a single string. =item $obj-EB([FILEHANDLE]) Print the header, body or whole message to file descriptor I. I<$fd> should be a reference to a GLOB. If I is not given the output will be sent to STDOUT. example: $mail->print( \*STDOUT ); # Print message to STDOUT =item $obj-EB([FILEHANDLE]) Print only the body to the FILEHANDLE (default STDOUT). =item $obj-EB([FILEHANDLE]) Print only the header to the FILEHANDLE (default STDOUT). =back =head2 Processing the header Most of these methods are simply wrappers around methods provided by L. =over 4 =item $obj-EB(PAIRS-of-FIELD) The PAIRS are field-name and field-content. For each PAIR, L is called. All fields are added after existing fields. The last addition is returned. =item $obj-EB(TAG, [WITH]) See L. =item $obj-EB(TAG, [TAGs]) Delete all fields with the name TAG. L is doing the work. =item $obj-EB([LENGTH]) See L. =item $obj-EB([TAG], [LENGTH]) See L. =item $obj-EB(TAG, [TAGs]) In LIST context, all fields with the name TAG are returned. In SCALAR context, only the first field which matches the earliest TAG is returned. L is called to collect the data. =item $obj-EB
([ARRAY-of-LINES]) See L. =item $obj-EB(PAIRS-of-FIELD) The PAIRS are field-name and field-content. For each PAIR, L is called with INDEX 0. If a FIELD is already in the header, it will be removed first. Do not specified the same field-name twice. =back =head2 Processing the body =over 4 =item $obj-EB([NLINES]) Attempts to remove a users signature from the body of a message. It does this by looking for a line equal to C<'-- '> within the last C of the message. If found then that line and all lines after it will be removed. If C is not given a default value of 10 will be used. This would be of most use in auto-reply scripts. =item $obj-EB(OPTIONS) Add your signature to the body. L will strip existing signatures first. -Option --Default File undef Signature [] =over 2 =item File => FILEHANDLE Take from the FILEHANDLE all lines starting from the first C<< -- >>. =item Signature => STRING|ARRAY-of-LINES =back =item $obj-EB() Removes all leading and trailing lines from the body that only contain white spaces. =back =head2 High-level functionality =over 4 =item $obj-EB() It can cause problems with some applications if a message contains a line starting with C<`From '>, in particular when attempting to split a folder. This method inserts a leading C<`>'> on any line that matches the regular expression C*From/> =item $obj-EB([OPTIONS]) Post an article via NNTP. Requires Net::NNTP to be installed. -Option--Default Debug Host Port 119 =over 2 =item Debug => BOOLEAN Debug value to pass to Net::NNTP, see L =item Host => HOSTNAME|Net::NNTP object Name of NNTP server to connect to, or a Net::NNTP object to use. =item Port => INTEGER Port number to connect to on remote host =back =item $obj-EB(OPTIONS) Create a new object with header initialised for a reply to the current object. And the body will be a copy of the current message indented. The C<.mailhdr> file in your home directory (if exists) will be read first, to provide defaults. -Option --Default Exclude [] Indent '>' Keep [] ReplyAll false =over 2 =item Exclude => ARRAY-of-FIELDS Remove the listed FIELDS from the produced message. =item Indent => STRING Use as indentation string. The string may contain C<%%> to get a single C<%>, C<%f> to get the first from name, C<%F> is the first character of C<%f>, C<%l> is the last name, C<%L> its first character, C<%n> the whole from string, and C<%I> the first character of each of the names in the from string. =item Keep => ARRAY-of-FIELDS Copy the listed FIELDS from the original message. =item ReplyAll => BOOLEAN Automatically include all To and Cc addresses of the original mail, excluding those mentioned in the Bcc list. =back =item $obj-EB([TYPE, [ARGS...]]) Send a Mail::Internet message using L. TYPE and ARGS are passed on to L. =item $obj-EB([OPTIONS]) Send a Mail::Internet message using direct SMTP. to the given ADDRESSES, each can be either a string or a reference to a list of email addresses. If none of C, or C are given then the addresses are extracted from the message being sent. The return value will be a list of email addresses that the message was sent to. If the message was not sent the list will be empty. Requires Net::SMTP and Net::Domain to be installed. -Option --Default Bcc undef Cc undef Debug Hello localhost.localdomain Host $ENV{SMTPHOSTS} MailFrom Mail::Util::mailaddress() Port 25 To undef =over 2 =item Bcc => ADDRESSES =item Cc => ADDRESSES =item Debug => BOOLEAN Debug value to pass to Net::SMPT, see =item Hello => STRING Send a HELO (or EHLO) command to the server with the given name. =item Host => HOSTNAME Name of the SMTP server to connect to, or a Net::SMTP object to use If C is not given then the SMTP host is found by attempting connections first to hosts specified in C<$ENV{SMTPHOSTS}>, a colon separated list, then C and C. =item MailFrom => ADDRESS The e-mail address which is used as sender. By default, L provides the address of the sender. =item Port => INTEGER Port number to connect to on remote host =item To => ADDRESSES =back =item $obj-EB(()) Remove the escaping added by L. =back =head1 SEE ALSO This module is part of the MailTools distribution, F. =head1 AUTHORS The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. Mail::Cap by Gisle Aas Eaas@oslonett.noE. Mail::Field::AddrList by Peter Orbaek Epoe@cit.dkE. Mail::Mailer and Mail::Send by Tim Bunce ETim.Bunce@ig.co.ukE. For other contributors see ChangeLog. =head1 LICENSE Copyrights 1995-2000 Graham Barr Egbarr@pobox.comE and 2001-2007 Mark Overmeer Eperl@overmeer.netE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F MailTools-2.13/lib/Mail/Field.pod0000644000175000001440000001162712262315737017256 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Field - Base class for manipulation of mail header fields =head1 INHERITANCE Mail::Field is extended by Mail::Field::AddrList Mail::Field::Date Mail::Field::Generic =head1 SYNOPSIS use Mail::Field; my $field = Mail::Field->new('Subject', 'some subject text'); my $field = Mail::Field->new(Subject => 'some subject text'); print $field->tag,": ",$field->stringify,"\n"; my $field = Mail::Field->subject('some subject text'); =head1 DESCRIPTION C creates and manipulates fields in MIME headers, collected within a L object. Different field types have their own sub-class (extension), defining additional useful accessors to the field content. People are invited to merge their implementation to special fields into MailTools, to maintain a consistent set of packages and documentation. =head1 METHODS =head2 Constructors Mail::Field (and it's sub-classes) define several methods which return new objects. These can all be categorized as constructor. =over 4 =item Mail::Field-EB(FIELDS) Take a LIST of C objects (which should all be of the same sub-class) and create a new object in that same class. =item Mail::Field-EB(TAG, HEAD [, INDEX ]) Takes as arguments the tag name, a C object and optionally an index. If the index argument is given then C will retrieve the given tag from the C object and create a new C based object. I will be returned in the field does not exist. If the index argument is not given the result depends on the context in which C is called. If called in a scalar context the result will be as if C was called with an index value of zero. If called in an array context then all tags will be retrieved and a list of C objects will be returned. =item Mail::Field-EB(TAG [, STRING | OPTIONS]) Create an object in the class which defines the field specified by the TAG argument. =back =head2 "Fake" constructors =over 4 =item $obj-EB(OPTIONS) This constructor is used internally with preprocessed field information. When called on an existing object, its original content will get replaced. =item $obj-EB() Parse a field line. =back =head2 Accessors =over 4 =item $obj-EB(OPTIONS) Change the settings (the content, but then smart) of this field. =item $obj-EB() Returns the field as a string. =item $obj-EB() =item Mail::Field-EB() Return the tag (in the correct case) for this item. Well, actually any casing is OK, because the field tags are treated case-insensitive; however people have some preferences. =back =head2 Smart accessors =over 4 =item $obj-EB([STRING]) Without arguments, the field is returned as L does. Otherwise, the STRING is parsed with L to replace the object's content. It is more clear to call either L or L directly, because this method does not add additional processing. =back =head1 DETAILS =head2 SUB-CLASS PACKAGE NAMES All sub-classes should be called Mail::Field::I where I is derived from the tag using these rules. =over 4 =item * Consider a tag as being made up of elements separated by '-' =item * Convert all characters to lowercase except the first in each element, which should be uppercase. =item * I is then created from these elements by using the first N characters from each element. =item * N is calculated by using the formula :- int((7 + #elements) / #elements) =item * I is then limited to a maximum of 8 characters, keeping the first 8 characters. =back For an example of this take a look at the definition of the C<_header_pkg_name()> subroutine in C =head1 DIAGNOSTICS =over 4 =item Error: Undefined subroutine called Mail::Field objects use autoloading to compile new functionality. Apparently, the method called is not implemented for the specific class of the field object. =back =head1 SEE ALSO This module is part of the MailTools distribution, F. =head1 AUTHORS The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. Mail::Cap by Gisle Aas Eaas@oslonett.noE. Mail::Field::AddrList by Peter Orbaek Epoe@cit.dkE. Mail::Mailer and Mail::Send by Tim Bunce ETim.Bunce@ig.co.ukE. For other contributors see ChangeLog. =head1 LICENSE Copyrights 1995-2000 Graham Barr Egbarr@pobox.comE and 2001-2007 Mark Overmeer Eperl@overmeer.netE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F MailTools-2.13/lib/Mail/Mailer/0000755000175000001440000000000012262315740016723 5ustar00markovusers00000000000000MailTools-2.13/lib/Mail/Mailer/smtp.pm0000644000175000001440000000366512262315737020264 0ustar00markovusers00000000000000# Copyrights 1995-2014 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. use strict; package Mail::Mailer::smtp; use vars '$VERSION'; $VERSION = '2.13'; use base 'Mail::Mailer::rfc822'; use Net::SMTP; use Mail::Util qw(mailaddress); use Carp; sub can_cc { 0 } sub exec { my ($self, $exe, $args, $to) = @_; my %opt = @$args; my $host = $opt{Server} || undef; $opt{Debug} ||= 0; my $smtp = Net::SMTP->new($host, %opt) or return undef; if($opt{Auth}) { $smtp->auth(@{$opt{Auth}}) or return undef; } ${*$self}{sock} = $smtp; $smtp->mail($opt{From} || mailaddress()); $smtp->to($_) for @$to; $smtp->data; untie *$self if tied *$self; tie *$self, 'Mail::Mailer::smtp::pipe', $self; $self; } sub set_headers($) { my ($self, $hdrs) = @_; $self->SUPER::set_headers ( { From => "<" . mailaddress() . ">" , %$hdrs , 'X-Mailer' => "Mail::Mailer[v$Mail::Mailer::VERSION] Net::SMTP[v$Net::SMTP::VERSION]" } ); } sub epilogue() { my $self = shift; my $sock = ${*$self}{sock}; my $ok = $sock->dataend; $sock->quit; delete ${*$self}{sock}; untie *$self; $ok; } sub close(@) { my ($self, @to) = @_; my $sock = ${*$self}{sock}; $sock && fileno $sock or return 1; my $ok = $self->epilogue; # Epilogue should destroy the SMTP filehandle, # but just to be on the safe side. $sock && fileno $sock or return $ok; close $sock or croak 'Cannot destroy socket filehandle'; $ok; } package Mail::Mailer::smtp::pipe; use vars '$VERSION'; $VERSION = '2.13'; sub TIEHANDLE { my ($class, $self) = @_; my $sock = ${*$self}{sock}; bless \$sock, $class; } sub PRINT { my $self = shift; my $sock = $$self; $sock->datasend( @_ ); } 1; MailTools-2.13/lib/Mail/Mailer/smtps.pm0000644000175000001440000000413112262315737020434 0ustar00markovusers00000000000000# Copyrights 1995-2014 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. # Based on smtp.pm, adapted by Maciej Żenczykowski use strict; package Mail::Mailer::smtps; use vars '$VERSION'; $VERSION = '2.13'; use base 'Mail::Mailer::rfc822'; use Net::SMTP::SSL; use Mail::Util qw(mailaddress); use Carp; sub can_cc { 0 } sub exec { my ($self, $exe, $args, $to) = @_; my %opt = @$args; my $host = $opt{Server} || undef; $opt{Debug} ||= 0; $opt{Port} ||= 465; my $smtp = Net::SMTP::SSL->new($host, %opt) or return undef; if($opt{Auth}) { $smtp->auth(@{$opt{Auth}}) or return undef; } ${*$self}{sock} = $smtp; $smtp->mail($opt{From} || mailaddress); $smtp->to($_) for @$to; $smtp->data; untie *$self if tied *$self; tie *$self, 'Mail::Mailer::smtps::pipe', $self; $self; } sub set_headers($) { my ($self, $hdrs) = @_; $self->SUPER::set_headers ( { From => "<" . mailaddress() . ">" , %$hdrs , 'X-Mailer' => "Mail::Mailer[v$Mail::Mailer::VERSION] " . " Net::SMTP[v$Net::SMTP::VERSION]" . " Net::SMTP::SSL[v$Net::SMTP::SSL::VERSION]" } ); } sub epilogue() { my $self = shift; my $sock = ${*$self}{sock}; my $ok = $sock->dataend; $sock->quit; delete ${*$self}{sock}; untie *$self; $ok; } sub close(@) { my ($self, @to) = @_; my $sock = ${*$self}{sock}; $sock && fileno $sock or return 1; my $ok = $self->epilogue; # Epilogue should destroy the SMTP filehandle, # but just to be on the safe side. $sock && fileno $sock or return $ok; close $sock or croak 'Cannot destroy socket filehandle'; $ok; } package Mail::Mailer::smtps::pipe; use vars '$VERSION'; $VERSION = '2.13'; sub TIEHANDLE { my ($class, $self) = @_; my $sock = ${*$self}{sock}; bless \$sock, $class; } sub PRINT { my $self = shift; my $sock = $$self; $sock->datasend( @_ ); } 1; MailTools-2.13/lib/Mail/Mailer/qmail.pm0000644000175000001440000000106412262315737020373 0ustar00markovusers00000000000000# Copyrights 1995-2014 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. use strict; package Mail::Mailer::qmail; use vars '$VERSION'; $VERSION = '2.13'; use base 'Mail::Mailer::rfc822'; sub exec($$$$) { my($self, $exe, $args, $to, $sender) = @_; my $address = defined $sender && $sender =~ m/\<(.*?)\>/ ? $1 : $sender; exec($exe, (defined $address ? "-f$address" : ())); die "ERROR: cannot run $exe: $!"; } 1; MailTools-2.13/lib/Mail/Mailer/testfile.pm0000644000175000001440000000225512262315737021112 0ustar00markovusers00000000000000# Copyrights 1995-2014 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. use strict; package Mail::Mailer::testfile; use vars '$VERSION'; $VERSION = '2.13'; use base 'Mail::Mailer::rfc822'; use Mail::Util qw/mailaddress/; my $num = 0; sub can_cc() { 0 } sub exec($$$) { my ($self, $exe, $args, $to) = @_; my $outfn = $Mail::Mailer::testfile::config{outfile} || 'mailer.testfile'; open F, '>>', $outfn or die "Cannot append message to testfile $outfn: $!"; print F "\n===\ntest ", ++$num, " ", (scalar localtime), "\nfrom: " . mailaddress(), "\nto: " . join(' ',@{$to}), "\n\n"; close F; untie *$self if tied *$self; tie *$self, 'Mail::Mailer::testfile::pipe', $self; $self; } sub close { 1 } package Mail::Mailer::testfile::pipe; use vars '$VERSION'; $VERSION = '2.13'; sub TIEHANDLE { my ($class, $self) = @_; bless \$self, $class; } sub PRINT { my $self = shift; open F, '>>', $Mail::Mailer::testfile::config{outfile} || 'mailer.testfile'; print F @_; close F; } 1; MailTools-2.13/lib/Mail/Mailer/sendmail.pm0000644000175000001440000000142012262315737021060 0ustar00markovusers00000000000000# Copyrights 1995-2014 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. use strict; package Mail::Mailer::sendmail; use vars '$VERSION'; $VERSION = '2.13'; use base 'Mail::Mailer::rfc822'; sub exec($$$$) { my($self, $exe, $args, $to, $sender) = @_; # Fork and exec the mailer (no shell involved to avoid risks) # We should always use a -t on sendmail so that Cc: and Bcc: work # Rumor: some sendmails may ignore or break with -t (AIX?) # Chopped out the @$to arguments, because -t means # they are sent in the body, and postfix complains if they # are also given on command line. exec( $exe, '-t', @$args ); } 1; MailTools-2.13/lib/Mail/Mailer/rfc822.pm0000644000175000001440000000115612262315737020300 0ustar00markovusers00000000000000# Copyrights 1995-2014 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. use strict; package Mail::Mailer::rfc822; use vars '$VERSION'; $VERSION = '2.13'; use base 'Mail::Mailer'; sub set_headers { my ($self, $hdrs) = @_; local $\ = ""; foreach (keys %$hdrs) { next unless m/^[A-Z]/; foreach my $h ($self->to_array($hdrs->{$_})) { $h =~ s/\n+\Z//; print $self "$_: $h\n"; } } print $self "\n"; # terminate headers } 1; MailTools-2.13/lib/Mail/Util.pm0000644000175000001440000000621312262315737016775 0ustar00markovusers00000000000000# Copyrights 1995-2014 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. use strict; package Mail::Util; use vars '$VERSION'; $VERSION = '2.13'; use base 'Exporter'; our @EXPORT_OK = qw(read_mbox maildomain mailaddress); use Carp; sub Version { our $VERSION } my ($domain, $mailaddress); my @sendmailcf = qw(/etc /etc/sendmail /etc/ucblib /etc/mail /usr/lib /var/adm/sendmail); sub read_mbox($) { my $file = shift; local *FH; open FH,'<', $file or croak "cannot open '$file': $!\n"; local $_; my @mbox; my $mail = []; my $blank = 1; while() { if($blank && /^From .*\d{4}/) { push @mbox, $mail if @$mail; $mail = [ $_ ]; $blank = 0; } else { $blank = m/^$/ ? 1 : 0; push @$mail, $_; } } push @mbox, $mail if @$mail; close FH; wantarray ? @mbox : \@mbox; } sub maildomain() { return $domain if defined $domain; $domain = $ENV{MAILDOMAIN} and return $domain; # Try sendmail configuration file my $config = (grep -r, map {"$_/sendmail.cf"} @sendmailcf)[0]; local *CF; local $_; if(defined $config && open CF, '<', $config) { my %var; while() { if(my ($v, $arg) = /^D([a-zA-Z])([\w.\$\-]+)/) { $arg =~ s/\$([a-zA-Z])/exists $var{$1} ? $var{$1} : '$'.$1/eg; $var{$v} = $arg; } } close CF; $domain = $var{j} if defined $var{j}; $domain = $var{M} if defined $var{M}; $domain = $1 if $domain && $domain =~ m/([A-Za-z0-9](?:[\.\-A-Za-z0-9]+))/; return $domain if defined $domain && $domain !~ /\$/; } # Try smail config file if exists if(open CF, '<', "/usr/lib/smail/config") { while() { if( /\A\s*hostnames?\s*=\s*(\S+)/ ) { $domain = (split /\:/,$1)[0]; last; } } close CF; return $domain if defined $domain; } # Try a SMTP connection to 'mailhost' if(eval {require Net::SMTP}) { foreach my $host (qw(mailhost localhost)) { # hosts are local, so short timeout my $smtp = eval { Net::SMTP->new($host, Timeout => 5) }; if(defined $smtp) { $domain = $smtp->domain; $smtp->quit; last; } } } # Use internet(DNS) domain name, if it can be found $domain = Net::Domain::domainname() if !defined $domain && eval {require Net::Domain}; $domain ||= "localhost"; } sub mailaddress(;$) { $mailaddress = shift if @_; return $mailaddress if defined $mailaddress; # Get user name from environment $mailaddress = $ENV{MAILADDRESS}; unless($mailaddress || $^O ne 'MacOS') { require Mac::InternetConfig; no strict; Mac::InternetConfig->import; $mailaddress = $InternetConfig{kICEmail()}; } $mailaddress ||= $ENV{USER} || $ENV{LOGNAME} || eval {getpwuid $>} || "postmaster"; # Add domain if it does not exist $mailaddress .= '@' . maildomain if $mailaddress !~ /\@/; $mailaddress =~ s/(^.*<|>.*$)//g; $mailaddress; } 1; MailTools-2.13/lib/Mail/Mailer.pod0000644000175000001440000000761212262315737017443 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Mailer - Simple interface to electronic mailing mechanisms =head1 INHERITANCE Mail::Mailer is a IO::Handle =head1 SYNOPSIS use Mail::Mailer; use Mail::Mailer qw(mail); # specifies default mailer $mailer = Mail::Mailer->new; $mailer = Mail::Mailer->new($type, @args); $mailer->open(\%headers); print $mailer $body; $mailer->close or die "couldn't send whole message: $!\n"; =head1 DESCRIPTION Sends mail using any of the built-in methods. As TYPE argument to L, you can specify any of =over 4 =item C Use the C program to deliver the mail. =item C Use the C protocol via Net::SMTP to deliver the mail. The server to use can be specified in C<@args> with $mailer = Mail::Mailer->new('smtp', Server => $server); The smtp mailer does not handle C and C lines, neither their C fellows. The C options enables debugging output from C. You may also use the C<< Auth => [ $user, $password ] >> option for SASL authentication. To make this work, you have to install the L distribution yourself: it is not automatically installed. =item C Use the smtp over ssl protocol via L to deliver the mail. Usage is identical to C. You have to install Authen::SASL as well. $mailer = Mail::Mailer->new('smtps', Server => $server); =item C Use qmail's qmail-inject program to deliver the mail. =item C Used for debugging, this displays the data to the file named in C<$Mail::Mailer::testfile::config{outfile}> which defaults to a file named C. No mail is ever sent. =back C will search for executables in the above order. The default mailer will be the first one found. =head1 METHODS =head2 Constructors =over 4 =item Mail::Mailer-EB(TYPE, ARGS) The TYPE is one of the back-end sender implementations, as described in the DESCRIPTION chapter of this manual page. The ARGS are passed to that back-end. =item $obj-EB(HASH) The HASH consists of key and value pairs, the key being the name of the header field (eg, C), and the value being the corresponding contents of the header field. The value can either be a scalar (eg, C) or a reference to an array of scalars (C<< eg, ['gnat@frii.com', 'Tim.Bunce@ig.co.uk'] >>). =back =head1 DETAILS =head2 ENVIRONMENT VARIABLES =over 4 =item PERL_MAILERS Augments/override the build in choice for binary used to send out our mail messages. Format: "type1:mailbinary1;mailbinary2;...:type2:mailbinaryX;...:..." Example: assume you want you use private sendmail binary instead of mailx, one could set C to: "mail:/does/not/exists:sendmail:$HOME/test/bin/sendmail" On systems which may include C<:> in file names, use C<|> as separator between type-groups. "mail:c:/does/not/exists|sendmail:$HOME/test/bin/sendmail" =back =head2 BUGS Mail::Mailer does not help with folding, and does not protect against various web-script hacker attacks, for instance where a new-line is inserted in the content of the field. =head1 SEE ALSO This module is part of the MailTools distribution, F. =head1 AUTHORS The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. Mail::Cap by Gisle Aas Eaas@oslonett.noE. Mail::Field::AddrList by Peter Orbaek Epoe@cit.dkE. Mail::Mailer and Mail::Send by Tim Bunce ETim.Bunce@ig.co.ukE. For other contributors see ChangeLog. =head1 LICENSE Copyrights 1995-2000 Graham Barr Egbarr@pobox.comE and 2001-2007 Mark Overmeer Eperl@overmeer.netE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F MailTools-2.13/lib/Mail/Header.pod0000644000175000001440000001731212262315737017420 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Header - manipulate MIME headers =head1 SYNOPSIS use Mail::Header; my $head = Mail::Header->new; my $head = Mail::Header->new( \*STDIN ); my $head = Mail::Header->new( [<>], Modify => 0); =head1 DESCRIPTION Read, write, create, and manipulate MIME headers, the leading part of each modern e-mail message, but also used in other protocols like HTTP. The fields are kept in L objects. Be aware that the header fields each have a name part, which shall be treated case-insensitive, and a content part, which may be folded over multiple lines. Mail::Header does not always follow the RFCs strict enough, does not help you with character encodings. It does not use weak references where it could (because those did not exist when the module was written) which costs some performance and make the implementation a little more complicated. The Mail::Message::Head implementation is much newer and therefore better. =head1 METHODS =head2 Constructors =over 4 =item $obj-EB() Create a duplicate of the current object. =item $obj-EB([ARG], [OPTIONS]) =item Mail::Header-EB([ARG], [OPTIONS]) ARG may be either a file descriptor (reference to a GLOB) or a reference to an array. If given the new object will be initialized with headers either from the array of read from the file descriptor. OPTIONS is a list of options given in the form of key-value pairs, just like a hash table. Valid options are -Option --Default FoldLength 79 MailFrom 'KEEP' Modify false =over 2 =item FoldLength => INTEGER The default length of line to be used when folding header lines. See L. =item MailFrom => 'IGNORE'|'COERCE'|'KEEP'|'ERROR' See method L. =item Modify => BOOLEAN If this value is I then the headers will be re-formatted, otherwise the format of the header lines will remain unchanged. =back =back =head2 "Fake" constructors Be warned that the next constructors all require an already created header object, of which the original content will be destroyed. =over 4 =item $obj-EB() Empty an existing C object of all lines. =item $obj-EB(ARRAY) Extract a header from the given array into an existing Mail::Header object. C B this array. Returns the object that the method was called on. =item $obj-EB
([ARRAY]) C
does multiple operations. First it will extract a header from the ARRAY, if given. It will then reformat the header (if reformatting is permitted), and finally return a reference to an array which contains the header in a printable form. =item $obj-EB([HASH]) As L, but it will eventually set headers from a hash reference, and it will return the headers as a hash reference. example: $fields->{From} = 'Tobias Brox '; $fields->{To} = ['you@somewhere', 'me@localhost']; $head->header_hashref($fields); =item $obj-EB(FILEHANDLE) Read a header from the given file descriptor into an existing Mail::Header object. =back =head2 Accessors =over 4 =item $obj-EB([TAG], [LENGTH]) Set the default fold length for all tags or just one. With no arguments the default fold length is returned. With two arguments it sets the fold length for the given tag and returns the previous value. If only C is given it sets the default fold length for the current object. In the two argument form C may be called as a static method, setting default fold lengths for tags that will be used by B C objects. See the C method for a description on how C uses these values. =item $obj-EB('IGNORE'|'COERCE'|'KEEP'|'ERROR') This specifies what to do when a C<`From '> line is encountered. Valid values are C - ignore and discard the header, C - invoke an error (call die), C - rename them as Mail-From and C - keep them. =item $obj-EB([VALUE]) If C is I then C will not do any automatic reformatting of the headers, other than to ensure that the line starts with the tags given. =back =head2 Processing =over 4 =item $obj-EB(TAG, LINE [, INDEX]) Add a new line to the header. If TAG is C the tag will be extracted from the beginning of the given line. If INDEX is given, the new line will be inserted into the header at the given point, otherwise the new line will be appended to the end of the header. =item $obj-EB() Returns the header as a single string. =item $obj-EB() Remove any header line that, other than the tag, only contains whitespace =item $obj-EB(TAG [, WITH]) Combine all instances of TAG into one. The lines will be joined together WITH, or a single space if not given. The new item will be positioned in the header where the first instance was, all other instances of TAG will be removed. =item $obj-EB(TAG) Returns the number of times the given atg appears in the header =item $obj-EB(TAG [, INDEX ]) Delete a tag from the header. If an INDEX id is given, then the Nth instance of the tag will be removed. If no INDEX is given, then all instances of tag will be removed. =item $obj-EB([LENGTH]) Fold the header. If LENGTH is not given, then C uses the following rules to determine what length to fold a line. =item $obj-EB(TAG [, INDEX]) Get the text from a line. If an INDEX is given, then the text of the Nth instance will be returned. If it is not given the return value depends on the context in which C was called. In an array context a list of all the text from all the instances of the TAG will be returned. In a scalar context the text for the first instance will be returned. The lines are unfolded, but still terminated with a new-line (see C) =item $obj-EB([FILEHANDLE]) Print the header to the given file descriptor, or C if no file descriptor is given. =item $obj-EB(TAG, LINE [, INDEX ]) Replace a line in the header. If TAG is C the tag will be extracted from the beginning of the given line. If INDEX is given the new line will replace the Nth instance of that tag, otherwise the first instance of the tag is replaced. If the tag does not appear in the header then a new line will be appended to the header. =item $obj-EB() Returns an array of all the tags that exist in the header. Each tag will only appear in the list once. The order of the tags is not specified. =item $obj-EB([TAG]) Unfold all instances of the given tag so that they do not spread across multiple lines. If C is not given then all lines are unfolded. The unfolding process is wrong but (for compatibility reasons) will not be repaired: only one blank at the start of the line should be removed, not all of them. =back =head1 SEE ALSO This module is part of the MailTools distribution, F. =head1 AUTHORS The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. Mail::Cap by Gisle Aas Eaas@oslonett.noE. Mail::Field::AddrList by Peter Orbaek Epoe@cit.dkE. Mail::Mailer and Mail::Send by Tim Bunce ETim.Bunce@ig.co.ukE. For other contributors see ChangeLog. =head1 LICENSE Copyrights 1995-2000 Graham Barr Egbarr@pobox.comE and 2001-2007 Mark Overmeer Eperl@overmeer.netE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F MailTools-2.13/lib/Mail/Send.pm0000644000175000001440000000220212262315737016743 0ustar00markovusers00000000000000# Copyrights 1995-2014 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. use strict; package Mail::Send; use vars '$VERSION'; $VERSION = '2.13'; use Carp; require Mail::Mailer; sub Version { our $VERSION } sub new(@) { my ($class, %attr) = @_; my $self = bless {}, $class; while(my($key, $value) = each %attr) { $key = lc $key; $self->$key($value); } $self; } sub set($@) { my ($self, $hdr, @values) = @_; $self->{$hdr} = [ @values ] if @values; @{$self->{$hdr} || []}; # return new (or original) values } sub add($@) { my ($self, $hdr, @values) = @_; push @{$self->{$hdr}}, @values; } sub delete($) { my($self, $hdr) = @_; delete $self->{$hdr}; } sub to { my $self=shift; $self->set('To', @_); } sub cc { my $self=shift; $self->set('Cc', @_); } sub bcc { my $self=shift; $self->set('Bcc', @_); } sub subject { my $self=shift; $self->set('Subject', join (' ', @_)); } sub open(@) { my $self = shift; Mail::Mailer->new(@_)->open($self); } 1; MailTools-2.13/lib/Mail/Util.pod0000644000175000001440000000612512262315740017137 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Util - mail utility functions =head1 INHERITANCE Mail::Util is a Exporter =head1 SYNOPSIS use Mail::Util qw( ... ); =head1 DESCRIPTION This package provides several mail related utility functions. Any function required must by explicitly listed on the use line to be exported into the calling package. =head1 FUNCTIONS =over 4 =item B([ADDRESS]) Return a guess at the current users mail address. The user can force the return value by setting the MAILADDRESS environment variable. [2.10] You may set the ADDRESS via the parameter. WARNING: When not supplied via the environment variable, looks at various configuration files and other environmental data. Although this seems to be smart behavior, this is not predictable enough (IMHO) to be used. Please set the MAILADDRESS explicitly, and do not trust on the "automatic detection", even when that produces a correct address (on the moment) example: # in your main script $ENV{MAILADDRESS} = 'me@example.com'; # everywhere else use Mail::Util 'mailaddress'; print mailaddress; # since v2.10 mailaddress "me@example.com"; =item B() Attempt to determine the current user mail domain string via the following methods =over 4 =item * Look for the MAILDOMAIN environment variable, which can be set from outside the program. This is by far the best way to configure the domain. =item * Look for a sendmail.cf file and extract DH parameter =item * Look for a smail config file and usr the first host defined in hostname(s) =item * Try an SMTP connect (if Net::SMTP exists) first to mailhost then localhost =item * Use value from Net::Domain::domainname (if Net::Domain exists) =back WARNING: On modern machines, there is only one good way to provide information to this method: the first; always explicitly configure the MAILDOMAIN. example: # in your main script $ENV{MAILDOMAIN} = 'example.com'; # everywhere else use Mail::Util 'maildomain'; print maildomain; =item B(FILE) Read FILE, a binmail mailbox file, and return a list of references. Each reference is a reference to an array containing one message. WARNING: This method does not quote lines which accidentally also start with the message separator C, so this implementation can be considered broken. See Mail::Box::Mbox =back =head1 SEE ALSO This module is part of the MailTools distribution, F. =head1 AUTHORS The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. Mail::Cap by Gisle Aas Eaas@oslonett.noE. Mail::Field::AddrList by Peter Orbaek Epoe@cit.dkE. Mail::Mailer and Mail::Send by Tim Bunce ETim.Bunce@ig.co.ukE. For other contributors see ChangeLog. =head1 LICENSE Copyrights 1995-2000 Graham Barr Egbarr@pobox.comE and 2001-2007 Mark Overmeer Eperl@overmeer.netE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F MailTools-2.13/lib/Mail/Cap.pm0000644000175000001440000001426012262315737016564 0ustar00markovusers00000000000000# Copyrights 1995-2014 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. package Mail::Cap; use vars '$VERSION'; $VERSION = '2.13'; use strict; sub Version { our $VERSION } our $useCache = 1; # don't evaluate tests every time my @path; if($^O eq "MacOS") { @path = split /\,/, $ENV{MAILCAPS} || "$ENV{HOME}mailcap"; } else { @path = split /\:/ , ( $ENV{MAILCAPS} || (defined $ENV{HOME} ? "$ENV{HOME}/.mailcap:" : '') . '/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap' ); # this path is specified under RFC1524 appendix A } sub new { my $class = shift; unshift @_, 'filename' if @_ % 2; my %args = @_; my $take_all = $args{take} && uc $args{take} eq 'ALL'; my $self = bless {_count => 0}, $class; $self->_process_file($args{filename}) if defined $args{filename} && -r $args{filename}; if(!defined $args{filename} || $take_all) { foreach my $fname (@path) { -r $fname or next; $self->_process_file($fname); last unless $take_all; } } unless($self->{_count}) { # Set up default mailcap $self->{'audio/*'} = [{'view' => "showaudio %s"}]; $self->{'image/*'} = [{'view' => "xv %s"}]; $self->{'message/rfc822'} = [{'view' => "xterm -e metamail %s"}]; } $self; } sub _process_file { my $self = shift; my $file = shift or return; local *MAILCAP; open MAILCAP, $file or return; $self->{_file} = $file; local $_; while() { next if /^\s*#/; # comment next if /^\s*$/; # blank line $_ .= # continuation line while s/(^|[^\\])((?:\\\\)*)\\\s*$/$1$2/; chomp; s/\0//g; # ensure no NULs in the line s/(^|[^\\]);/$1\0/g; # make field separator NUL my ($type, $view, @parts) = split /\s*\0\s*/; $type .= "/*" if $type !~ m[/]; $view =~ s/\\;/;/g; $view =~ s/\\\\/\\/g; my %field = (view => $view); foreach (@parts) { my($key, $val) = split /\s*\=\s*/, $_, 2; if(defined $val) { $val =~ s/\\;/;/g; $val =~ s/\\\\/\\/g; $field{$key} = $val; } else { $field{$key} = 1; } } if(my $test = $field{test}) { unless ($test =~ /\%/) { # No parameters in test, can perform it right away system $test; next if $?; } } # record this entry unless(exists $self->{$type}) { $self->{$type} = []; $self->{_count}++; } push @{$self->{$type}}, \%field; } close MAILCAP; } sub view { my $self = shift; $self->_run($self->viewCmd(@_)) } sub compose { my $self = shift; $self->_run($self->composeCmd(@_)) } sub edit { my $self = shift; $self->_run($self->editCmd(@_)) } sub print { my $self = shift; $self->_run($self->printCmd(@_)) } sub _run($) { my ($self, $cmd) = @_; defined $cmd or return 0; system $cmd; 1; } sub viewCmd { shift->_createCommand(view => @_) } sub composeCmd { shift->_createCommand(compose => @_) } sub editCmd { shift->_createCommand(edit => @_) } sub printCmd { shift->_createCommand(print => @_) } sub _createCommand($$$) { my ($self, $method, $type, $file) = @_; my $entry = $self->getEntry($type, $file); $entry && exists $entry->{$method} or return undef; $self->expandPercentMacros($entry->{$method}, $type, $file); } sub makeName($$) { my ($self, $type, $basename) = @_; my $template = $self->nametemplate($type) or return $basename; $template =~ s/%s/$basename/g; $template; } sub field($$) { my($self, $type, $field) = @_; my $entry = $self->getEntry($type); $entry->{$field}; } sub description { shift->field(shift, 'description'); } sub textualnewlines { shift->field(shift, 'textualnewlines'); } sub x11_bitmap { shift->field(shift, 'x11-bitmap'); } sub nametemplate { shift->field(shift, 'nametemplate'); } sub getEntry { my($self, $origtype, $file) = @_; return $self->{_cache}{$origtype} if $useCache && exists $self->{_cache}{$origtype}; my ($fulltype, @params) = split /\s*;\s*/, $origtype; my ($type, $subtype) = split m[/], $fulltype, 2; $subtype ||= ''; my $entry; foreach (@{$self->{"$type/$subtype"}}, @{$self->{"$type/*"}}) { if(exists $_->{'test'}) { # must run test to see if it applies my $test = $self->expandPercentMacros($_->{'test'}, $origtype, $file); system $test; next if $?; } $entry = { %$_ }; # make copy last; } $self->{_cache}{$origtype} = $entry if $useCache; $entry; } sub expandPercentMacros { my ($self, $text, $type, $file) = @_; defined $type or return $text; defined $file or $file = ""; my ($fulltype, @params) = split /\s*;\s*/, $type; ($type, my $subtype) = split m[/], $fulltype, 2; my %params; foreach (@params) { my($key, $val) = split /\s*=\s*/, $_, 2; $params{$key} = $val; } $text =~ s/\\%/\0/g; # hide all escaped %'s $text =~ s/%t/$fulltype/g; # expand %t $text =~ s/%s/$file/g; # expand %s { # expand %{field} local $^W = 0; # avoid warnings when expanding %params $text =~ s/%\{\s*(.*?)\s*\}/$params{$1}/g; } $text =~ s/\0/%/g; $text; } # This following procedures can be useful for debugging purposes sub dumpEntry { my($hash, $prefix) = @_; defined $prefix or $prefix = ""; print "$prefix$_ = $hash->{$_}\n" for sort keys %$hash; } sub dump { my $self = shift; foreach (keys %$self) { next if /^_/; print "$_\n"; foreach (@{$self->{$_}}) { dumpEntry($_, "\t"); print "\n"; } } if(exists $self->{_cache}) { print "Cached types\n"; print "\t$_\n" for keys %{$self->{_cache}}; } } 1; MailTools-2.13/lib/Mail/Field/0000755000175000001440000000000012262315740016535 5ustar00markovusers00000000000000MailTools-2.13/lib/Mail/Field/Date.pm0000644000175000001440000000215312262315737017757 0ustar00markovusers00000000000000# Copyrights 1995-2014 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. use strict; package Mail::Field::Date; use vars '$VERSION'; $VERSION = '2.13'; use base 'Mail::Field'; use Date::Format qw(time2str); use Date::Parse qw(str2time); (bless [])->register('Date'); sub set() { my $self = shift; my $arg = @_ == 1 ? shift : { @_ }; foreach my $s (qw(Time TimeStr)) { if(exists $arg->{$s}) { $self->{$s} = $arg->{$s} } else { delete $self->{$s} } } $self; } sub parse($) { my $self = shift; delete $self->{Time}; $self->{TimeStr} = shift; $self; } sub time(;$) { my $self = shift; if(@_) { delete $self->{TimeStr}; return $self->{Time} = shift; } $self->{Time} ||= str2time $self->{TimeStr}; } sub stringify { my $self = shift; $self->{TimeStr} ||= time2str("%a, %e %b %Y %T %z", $self->time); } sub reformat { my $self = shift; $self->time($self->time); $self->stringify; } 1; MailTools-2.13/lib/Mail/Field/Date.pod0000644000175000001440000000555512262315737020136 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Field::Date - a date header field =head1 INHERITANCE Mail::Field::Date is a Mail::Field =head1 SYNOPSIS use HTTP::Date 'time2iso'; my $field = Mail::Field->new(Date => time2iso()); =head1 DESCRIPTION Represents one "Date" header field. See L. =head1 METHODS See L. =head2 Constructors See L. =over 4 =item Mail::Field::Date-EB(FIELDS) See L =item Mail::Field::Date-EB(TAG, HEAD [, INDEX ]) See L =item Mail::Field::Date-EB(TAG [, STRING | OPTIONS]) See L =back =head2 "Fake" constructors See L. =over 4 =item $obj-EB(OPTIONS) See L =item $obj-EB() See L =back =head2 Accessors See L. =over 4 =item $obj-EB(OPTIONS) -Option --Default Time undef TimeStr undef =over 2 =item Time => SECONDS =item TimeStr => STRING A string acceptable to Date::Parse. =back =item $obj-EB() See L =item $obj-EB() =item Mail::Field::Date-EB() See L =back =head2 Smart accessors See L. =over 4 =item $obj-EB([STRING]) See L =item $obj-EB