Mail-Sendmail-0.80/000755 000765 000024 00000000000 13146360467 014323 5ustar00neilbstaff000000 000000 Mail-Sendmail-0.80/Changes000644 000765 000024 00000013117 13146360467 015621 0ustar00neilbstaff000000 000000 Revision history for Perl module Mail::Sendmail 0.80 2017-08-20 NEILB - NEILB got co-maint to do a release that includes META.yml and META.json. - Switched to Dist::Zilla. - Added COPYRIGHT section to pod. - Fixed the NAME section in pod to follow expected format. - Added "use warnings" and fixed all the warnings. - Manually set $VERSION, as it's used in the code 0.79_16 2006-07-08 MIVKOVIC - experimental SMTP AUTH support (LOGIN PLAIN CRAM-MD5 DIGEST-MD5) - Fix bug where one refused RCPT TO: would abort everything - send EHLO, and parse response (for later AUTH implementation) - better handling of multi-line responses, and better error-messages - Also normalize line endings in headers - Now keeps the Sender header if it was used. Previous versions only used it for the MAIL FROM: command and deleted it. - No space between "MAIL FROM:" or "RCPT TO:" and address. 0.79 2003-02-06 MIVKOVIC - Public release with the changes that were in 0.78_2, 0.78_3, 0.78_5, and 0.78_6. 0.78_6 2003-02-06 - Remove old configuration variables from version 0.74. - document $mail{Sender} - add seconds to Date header (some buggy mailers freak out if the time has no seconds) - added "/" (\x2F) as a valid character in mailbox part. - minor documentation updates 0.78_5 2002-08-24 MIVKOVIC - Adapt reference to mail headers in module to new case convention (bug introduced in 0.78_2). - ppd and PPM install changes... 0.78_3 2002-08-11 MIVKOVIC - support multi-line responses - define local $\ and $_ in &sendmail to protect us from outside settings (is this really needed?) - delete $mail{Sender} used for envelope sender, but not needed as header - internal rewrite using subs to send and receive on socket 0.78_2 2002-08-11 MIVKOVIC - fix old bug with dot as 76th char disappearing. - correct very old bug where port number was not extracted from stuff like 'my.server:2525'. - fix time_to_date bug with negative half-hour zones (only Newfoundland?) - use Sys::Hostname to get the hostname for HELO. (I think it has been part of the standard distribution for many years now) - support different envelope sender through $mail{Sender} - Change case of headers: first character after "-" also uppercased now, so people who believe this is required because Outlook does it this way stop complaining. :-) - Enable full session output for debugging - Do not copy the mail message again to a different variable. - Minor documentation changes. 0.78 2000-09-25 MIVKOVIC - Now accepts single-letter host/domain names in addresses. They were previously rejected, due to my misunderstanding of an RFC. - Removed smtp.site1.csi.com from the default servers. That server is not an open relay any more. This leaves only 'localhost' in the servers list. 0.77 1999-03-28 MIVKOVIC - If connection to 1st server failed, the others failed too, but only with certain Perl-version/OS combinations !?!. Fixed (hopefuly). 0.76 1999-03-27 MIVKOVIC - fixed bug which prevented trying other servers in list if connection to first failed. - fixed reporting of server in log. 0.75 1999-03-27 MIVKOVIC - you can now send attachments, html mail etc... your headers will be left alone. - can use a list of possible SMTP servers instead of a single one. - all configuration now grouped in a %mailcfg hash. - removes possible extra line-endings in headers. - e-mail address regex changes: . now accepts user@[xxx.xxx.xxx.xxx] . now refuses commas (they are only valid in quoted strings which $address_rx does not support). Comma separated recipients lists now work even with no space after the comma. - if you used an X-mailer header, the Mail::Sendmail vwersion was appended. It isn't any more. - removed unnecessary BEGIN{} block. - no more warnings on empty Subject. - lots's of cleaning up in the code. 0.74 1998-08-01 MIVKOVIC - Fixed $/ problem: mailing would hang if caller had redefined the record separator. It's now locally set to "\015\012". - corrected reading of %mail hash passed to sendmail: it would abort on a false value (the trap is clearly mentionned in the perl docs: shame on me!) - added configurable retries when failure to connect to server - much more error checking - more warnings to STDERR, but only if running with -w flag. - changed $address_rx, so it accepts user@hostname, not only user@host.top, and also accepts weird but legal characters - Message body is now all of Message, Body and Text instead of the first not empty one (if you don't mind the final message being in random order, you can now be really sloppy when filling in the message from your script!). - use strict. - Added Makefile.PL. - updated doc 0.73 1998-07-13 MIVKOVIC - Line endings changed again to be Mac compatible at last. - Automatic time zone detection. - Support for SMTP Port change for single messages. - Always default to quoted-printable encoding if possible. - Added $Mail::Sendmail::default_sender. 0.72 1998-07-08 MIVKOVIC - Fixed line endings in Body to "\r\n". - MIME quoted-printable encoding is now automatic if needed. - Test script can now run unattended. 0.71 1998-07-07 MIVKOVIC - Fixed Time Zone bug with AS port. - Added half-hour Time Zone support. - Repackaged with \n line endings instead of \r\n. 0.70 1998-06-18 MIVKOVIC - First release to CPAN Mail-Sendmail-0.80/dist.ini000644 000765 000024 00000000432 13146360467 015766 0ustar00neilbstaff000000 000000 name = Mail-Sendmail author = Milivoj Ivkovic license = Perl_5 copyright_holder = Milivoj Ivkovic copyright_year = 1998 version = 0.80 [@Filter] -bundle = @Basic -remove = Readme [AutoPrereqs] [MetaJSON] [GithubMeta] [Git::Tag] tag_message= [Git::Push] Mail-Sendmail-0.80/lib/000755 000765 000024 00000000000 13146360467 015071 5ustar00neilbstaff000000 000000 Mail-Sendmail-0.80/LICENSE000644 000765 000024 00000043666 13146360467 015347 0ustar00neilbstaff000000 000000 This software is copyright (c) 1998 by Milivoj Ivkovic. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 1998 by Milivoj Ivkovic. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. 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. 10. 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 Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 1998 by Milivoj Ivkovic. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Mail-Sendmail-0.80/Makefile.PL000644 000765 000024 00000002467 13146360467 016306 0ustar00neilbstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.006. use strict; use warnings; use 5.006; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Simple platform independent mailer", "AUTHOR" => "Milivoj Ivkovic ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Mail-Sendmail", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.006", "NAME" => "Mail::Sendmail", "PREREQ_PM" => { "Digest::MD5" => 0, "Exporter" => 0, "MIME::Base64" => 0, "Socket" => 0, "Sys::Hostname" => 0, "Time::Local" => 0, "parent" => 0, "strict" => 0, "vars" => 0, "warnings" => 0 }, "VERSION" => "0.80", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Digest::MD5" => 0, "Exporter" => 0, "MIME::Base64" => 0, "Socket" => 0, "Sys::Hostname" => 0, "Time::Local" => 0, "parent" => 0, "strict" => 0, "vars" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Mail-Sendmail-0.80/MANIFEST000644 000765 000024 00000000300 13146360467 015445 0ustar00neilbstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.006. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README Todo dist.ini lib/Mail/Sendmail.pm t/original.t Mail-Sendmail-0.80/META.json000644 000765 000024 00000002455 13146360467 015752 0ustar00neilbstaff000000 000000 { "abstract" : "Simple platform independent mailer", "author" : [ "Milivoj Ivkovic " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.006, CPAN::Meta::Converter version 2.150005", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Mail-Sendmail", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Digest::MD5" : "0", "Exporter" : "0", "MIME::Base64" : "0", "Socket" : "0", "Sys::Hostname" : "0", "Time::Local" : "0", "parent" : "0", "perl" : "5.006", "strict" : "0", "vars" : "0", "warnings" : "0" } } }, "release_status" : "stable", "resources" : { "homepage" : "https://github.com/neilb/Mail-Sendmail", "repository" : { "type" : "git", "url" : "https://github.com/neilb/Mail-Sendmail.git", "web" : "https://github.com/neilb/Mail-Sendmail" } }, "version" : "0.80", "x_serialization_backend" : "Cpanel::JSON::XS version 3.0217" } Mail-Sendmail-0.80/META.yml000644 000765 000024 00000001401 13146360467 015570 0ustar00neilbstaff000000 000000 --- abstract: 'Simple platform independent mailer' author: - 'Milivoj Ivkovic ' build_requires: {} configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.006, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Mail-Sendmail requires: Digest::MD5: '0' Exporter: '0' MIME::Base64: '0' Socket: '0' Sys::Hostname: '0' Time::Local: '0' parent: '0' perl: '5.006' strict: '0' vars: '0' warnings: '0' resources: homepage: https://github.com/neilb/Mail-Sendmail repository: https://github.com/neilb/Mail-Sendmail.git version: '0.80' x_serialization_backend: 'YAML::Tiny version 1.62' Mail-Sendmail-0.80/README000644 000765 000024 00000001544 13146360467 015207 0ustar00neilbstaff000000 000000 Perl 5 module Mail::Sendmail Mail::Sendmail is a pure perl module that provides a simple platform-independent mailer. INSTALLATION You install Mail::Sendmail by running these commands in the *nix environment: perl Makefile.PL make make test (optional) make install If you have a CPAN client installed, you should be able to run something like: cpan Mail::Sendmail cpanm Mail::Sendmail DOCUMENTATION POD format documentation is included in lib/IO/Tee.pm. You can read the documentation online: https://metacpan.org/pod/Mail::Sendmail Or read it on your terminal, using the perldoc command: perldoc Mail::Sendmail COPYRIGHT Copyright (C) 1998-2017 Milivoj Ivkovic AUTHOR This module was created by Milivoj Ivkovic (mivkovic) . but is currently (as of August 2017) being maintained by Neil Bowers (NEILB). Mail-Sendmail-0.80/t/000755 000765 000024 00000000000 13146360467 014566 5ustar00neilbstaff000000 000000 Mail-Sendmail-0.80/Todo000644 000765 000024 00000002711 13146360467 015154 0ustar00neilbstaff000000 000000 # random thoughts about what to do next. # suggestions welcome - CLEANUP THE MESS! - Also MIME-encode headers if they contain accented characters Make it configurable? - Document AUTH - Also accept hashrefs in place of hashes - Update web site . check with no wanted AUTH method specified - Also accept MIME::Lite objects? YES! It should be easy, except maybe if mail was built with filehandles? . Is use vars in sub OK ? And with mod_perl? . option for stricter email address checker . problems on Win32 with Perl 5.8.0 and CygWin? (see emails) - Check on older Perl - cleanup and widely test SMTP AUTH support - Check with mod_perl - During Makefile.PL, try to find a local SMTP server and the user's e-mail address, and offer to pre-configure these as defaults in Sendmail.pm. And let the user enter defaults to override automatic detection. - Document $address_rx: which addresses it finds OK, and which not. - Add example scripts for CGI forms - Create sourceforge site and mailing list - Does the test say OK if no mail could be sent? check and fix Have make dist generate README and html ? Add install.ppm for PPM installs? Use 8BITMIME if available from server? Encode only if accented chars really present? Rename to Mail::Simple? This is not on my todo list anymore, because it looks like nobody is using Perl on Amiga: - Setup Perl on an Amiga and see if it runs. (it should) (but if someone tries it, I would appreciate knowing about it) Mail-Sendmail-0.80/t/original.t000755 000765 000024 00000003604 13146360467 016565 0ustar00neilbstaff000000 000000 #!/usr/bin/perl -w # unattended Mail::Sendmail test, sends a message to the author # but you probably want to change $mail{To} below # to send the message to yourself. # version 0.78 # if you change your mail server, you may need to change the From: # address below. $mail{From} = 'Sendmail Test '; $mail{To} = 'Sendmail Test '; #$mail{To} = 'Sendmail Test , You me@myaddress'; # if you want to get a copy of the test mail, you need to specify your # own server here, by name or IP address $server = 'mail.alma.ch'; #$server = 'my.usual.mail.server'; BEGIN { $| = 1; print "1..2\n"; } END {print "not ok 1\n" unless $loaded;} print < # see embedded POD documentation after __END__ # or http://alma.ch/perl/mail.html =head1 NAME Mail::Sendmail - Simple platform independent mailer =cut require 5.006; our $VERSION = "0.80"; use strict; use warnings; use parent 'Exporter'; # *************** Configuration you may want to change ******************* # You probably want to set your SMTP server here (unless you specify it in # every script), and leave the rest as is. See pod documentation for details our %mailcfg = ( # List of SMTP servers: 'smtp' => [ qw( localhost ) ], #'smtp' => [ qw( mail.mydomain.com ) ], # example 'from' => '', # default sender e-mail, used when no From header in mail 'mime' => 1, # use MIME encoding by default 'retries' => 1, # number of retries on smtp connect failure 'delay' => 1, # delay in seconds between retries 'tz' => '', # only to override automatic detection 'port' => 25, # change it if you always use a non-standard port 'debug' => 0 # prints stuff to STDERR ); # ******************************************************************* our $address_rx; our $debug; our $log; our $error; our $retry_delay; our $connect_retries; our $auth_support; use Socket; use Time::Local; # for automatic time zone detection use Sys::Hostname; # for use of hostname in HELO #use Digest::HMAC_MD5 qw(hmac_md5 hmac_md5_hex); $auth_support = 'DIGEST-MD5 CRAM-MD5 PLAIN LOGIN'; # use MIME::QuotedPrint if available and configured in %mailcfg eval("use MIME::QuotedPrint"); $mailcfg{'mime'} &&= (!$@); our @EXPORT = qw(&sendmail); our @EXPORT_OK = qw( %mailcfg time_to_date $address_rx $debug $log $error ); # regex for e-mail addresses where full=$1, user=$2, domain=$3 # see pod documentation about this regex my $word_rx = '[\x21\x23-\x27\x2A-\x2B\x2D\x2F\w\x3D\x3F]+'; my $user_rx = $word_rx # valid chars .'(?:\.' . $word_rx . ')*' # possibly more words preceded by a dot ; my $dom_rx = '\w[-\w]*(?:\.\w[-\w]*)*'; # less valid chars in domain names my $ip_rx = '\[\d{1,3}(?:\.\d{1,3}){3}\]'; $address_rx = '((' . $user_rx . ')\@(' . $dom_rx . '|' . $ip_rx . '))'; ; # v. 0.61 sub _require_md5 { eval { require Digest::MD5; Digest::MD5->import(qw(md5 md5_hex)); }; $error .= $@ if $@; return ($@ ? undef : 1); } sub _require_base64 { eval { require MIME::Base64; MIME::Base64->import(qw(encode_base64 decode_base64)); }; $error .= $@ if $@; return ($@ ? undef : 1); } sub _hmac_md5 { my ($pass, $ckey) = @_; my $size = 64; $pass = md5($pass) if length($pass) > $size; my $ipad = $pass ^ (chr(0x36) x $size); my $opad = $pass ^ (chr(0x5c) x $size); return md5_hex($opad, md5($ipad, $ckey)); } sub _digest_md5 { my ($user, $pass, $challenge, $realm) = @_; my %ckey = map { /^([^=]+)="?(.+?)"?$/ } split(/,/, $challenge); $realm ||= $ckey{realm}; #($user =~ s/\@(.+)$//o) ? $1 : $server; my $nonce = $ckey{nonce}; my $cnonce = &make_cnonce; my $uri = join('/', 'smtp', hostname()||'localhost', $ckey{realm}); my $qop = 'auth'; my $nc = '00000001'; my($hv, $a1, $a2); $hv = md5("$user:$realm:$pass"); $a1 = md5_hex("$hv:$nonce:$cnonce"); $a2 = md5_hex("AUTHENTICATE:$uri"); $hv = md5_hex("$a1:$nonce:$nc:$cnonce:$qop:$a2"); return qq(username="$user",realm="$ckey{realm}",nonce="$nonce",nc=$nc,cnonce="$cnonce",digest-uri="$uri",response=$hv,qop=$qop); } sub make_cnonce { my $s = '' ; for(1..16) { $s .= chr(rand 256) } $s = encode_base64($s, ""); $s =~ s/\W/X/go; return substr($s, 0, 16); } sub time_to_date { # convert a time() value to a date-time string according to RFC 822 my $time = $_[0] || time(); # default to now if no argument my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my @wdays = qw(Sun Mon Tue Wed Thu Fri Sat); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); my $TZ = $mailcfg{'tz'}; if ( $TZ eq "" ) { # offset in hours my $offset = sprintf "%.1f", (timegm(localtime) - time) / 3600; my $minutes = sprintf "%02d", abs( $offset - int($offset) ) * 60; $TZ = sprintf("%+03d", int($offset)) . $minutes; } return join(" ", ($wdays[$wday] . ','), $mday, $months[$mon], $year+1900, sprintf("%02d:%02d:%02d", $hour, $min, $sec), $TZ ); } # end sub time_to_date sub sendmail { $error = ''; $log = "Mail::Sendmail v. $VERSION - " . scalar(localtime()) . "\n"; my $CRLF = "\015\012"; local $/ = $CRLF; local $\ = ''; # to protect us from outside settings local $_; my (%mail, $k, $smtp, $server, $port, $connected, $localhost, $fromaddr, $recip, @recipients, $to, $header, %esmtp, @wanted_methods, ); use vars qw($server_reply); # -------- a few internal subs ---------- sub fail { # things to do before returning a sendmail failure $error .= join(" ", @_) . "\n"; if ($server_reply) { $error .= "Server said: $server_reply\n"; print STDERR "Server said: $server_reply\n" if $^W; } close S; return 0; } sub socket_write { my $i; for $i (0..$#_) { # accept references, so we don't copy potentially big data my $data = ref($_[$i]) ? $_[$i] : \$_[$i]; if ($mailcfg{'debug'} > 5) { if (length($$data) < 500) { print ">", $$data; } else { print "> [...", length($$data), " bytes sent ...]\n"; } } print(S $$data) || return 0; } 1; } sub socket_read { $server_reply = ""; do { $_ = ; $server_reply .= $_; #chomp $_; print "<$_" if $mailcfg{'debug'} > 5; if (/^[45]/ or !$_) { chomp $server_reply; return; # return false } } while (/^[\d]+-/); chomp $server_reply; return $server_reply; } # -------- end of internal subs ---------- # all config keys to lowercase, to prevent typo errors foreach $k (keys %mailcfg) { if ($k =~ /[A-Z]/) { $mailcfg{lc($k)} = $mailcfg{$k}; } } # redo mail hash, arranging keys case etc... while (@_) { $k = shift @_; if (!$k and $^W) { warn "Received false mail hash key: \'$k\'. Did you forget to put it in quotes?\n"; } # arrange keys case $k = ucfirst lc($k); $k =~ s/\s*:\s*$//o; # kill colon (and possible spaces) at end, we add it later. # uppercase also after "-", so people don't complain that headers case is different # than in Outlook. $k =~ s/-(.)/"-" . uc($1)/ge; $mail{$k} = shift @_; if ($k !~ /^(Message|Body|Text)$/i) { # normalize possible line endings in headers $mail{$k} =~ s/\015\012?/\012/go; $mail{$k} =~ s/\012/$CRLF/go; } } $smtp = $mail{'Smtp'} || $mail{'Server'}; unshift @{$mailcfg{'smtp'}}, $smtp if ($smtp and $mailcfg{'smtp'}->[0] ne $smtp); # delete non-header keys, so we don't send them later as mail headers # I like this syntax, but it doesn't seem to work with AS port 5.003_07: # delete @mail{'Smtp', 'Server'}; # so instead: delete $mail{'Smtp'}; delete $mail{'Server'}; $mailcfg{'port'} = $mail{'Port'} || $mailcfg{'port'} || 25; delete $mail{'Port'}; my $auth = $mail{'Auth'}; delete $mail{'Auth'}; my @parts; push(@parts, $mail{'Message'}) if defined($mail{'Message'}); push(@parts, $mail{'Body'}) if defined($mail{'Body'}); push(@parts, $mail{'Text'}) if defined($mail{'Text'}); $mail{'Message'} = join("", @parts); # delete @mail{'Body', 'Text'}; delete $mail{'Body'}; delete $mail{'Text'}; # Extract 'From:' e-mail address to use as envelope sender $fromaddr = $mail{'Sender'} || $mail{'From'} || $mailcfg{'from'}; #delete $mail{'Sender'}; unless ($fromaddr =~ /$address_rx/) { return fail("Bad or missing From address: \'$fromaddr\'"); } $fromaddr = $1; # add Date header if needed $mail{Date} ||= time_to_date() ; $log .= "Date: $mail{Date}\n"; # cleanup message, and encode if needed $mail{'Message'} =~ s/\r\n/\n/go; # normalize line endings, step 1 of 2 (next step after MIME encoding) $mail{'Mime-Version'} ||= '1.0'; $mail{'Content-Type'} ||= 'text/plain; charset="iso-8859-1"'; unless ( $mail{'Content-Transfer-Encoding'} || $mail{'Content-Type'} =~ /multipart/io ) { if ($mailcfg{'mime'}) { $mail{'Content-Transfer-Encoding'} = 'quoted-printable'; $mail{'Message'} = encode_qp($mail{'Message'}); } else { $mail{'Content-Transfer-Encoding'} = '8bit'; if ($mail{'Message'} =~ /[\x80-\xFF]/o) { $error .= "MIME::QuotedPrint not present!\nSending 8bit characters, hoping it will come across OK.\n"; warn "MIME::QuotedPrint not present!\n", "Sending 8bit characters without encoding, hoping it will come across OK.\n" if $^W; } } } $mail{'Message'} =~ s/^\./\.\./gom; # handle . as first character $mail{'Message'} =~ s/\n/$CRLF/go; # normalize line endings, step 2. # Get recipients { # don't warn for undefined values below my @recipients; push(@recipients, $mail{To}) if defined($mail{To}); push(@recipients, $mail{Cc}) if defined($mail{Cc}); push(@recipients, $mail{Bcc}) if defined($mail{Bcc}); $recip = join(", ", @recipients); } delete $mail{'Bcc'}; @recipients = (); while ($recip =~ /$address_rx/go) { push @recipients, $1; } unless (@recipients) { return fail("No recipient!") } # get local hostname for polite HELO $localhost = hostname() || 'localhost'; foreach $server ( @{$mailcfg{'smtp'}} ) { # open socket needs to be inside this foreach loop on Linux, # otherwise all servers fail if 1st one fails !??! why? unless ( socket S, AF_INET, SOCK_STREAM, scalar(getprotobyname 'tcp') ) { return fail("socket failed ($!)") } print "- trying $server\n" if $mailcfg{'debug'} > 1; $server =~ s/\s+//go; # remove spaces just in case of a typo # extract port if server name like "mail.domain.com:2525" $port = ($server =~ s/:(\d+)$//o) ? $1 : $mailcfg{'port'}; $smtp = $server; # save $server for use outside foreach loop my $smtpaddr = inet_aton $server; unless ($smtpaddr) { $error .= "$server not found\n"; next; # next server } my $retried = 0; # reset retries for each server while ( ( not $connected = connect S, pack_sockaddr_in($port, $smtpaddr) ) and ( $retried < $mailcfg{'retries'} ) ) { $retried++; $error .= "connect to $server failed ($!)\n"; print "- connect to $server failed ($!)\n" if $mailcfg{'debug'} > 1; print "retrying in $mailcfg{'delay'} seconds...\n" if $mailcfg{'debug'} > 1; sleep $mailcfg{'delay'}; } if ( $connected ) { print "- connected to $server\n" if $mailcfg{'debug'} > 3; last; } else { $error .= "connect to $server failed\n"; print "- connect to $server failed, next server...\n" if $mailcfg{'debug'} > 1; next; # next server } } unless ( $connected ) { return fail("connect to $smtp failed ($!) no (more) retries!") }; { local $^W = 0; # don't warn on undefined variables # Add info to log variable $log .= "Server: $smtp Port: $port\n" . "From: $fromaddr\n" . "Subject: $mail{Subject}\n" ; } my($oldfh) = select(S); $| = 1; select($oldfh); socket_read() || return fail("Connection error from $smtp on port $port ($_)"); socket_write("EHLO $localhost$CRLF") || return fail("send EHLO error (lost connection?)"); my $ehlo = socket_read(); if ($ehlo) { # parse EHLO response map { s/^\d+[- ]//; my ($k, $v) = split /\s+/, $_, 2; $esmtp{$k} = $v || 1 if $k; } split(/\n/, $ehlo); } else { # try plain HELO instead socket_write("HELO $localhost$CRLF") || return fail("send HELO error (lost connection?)"); } if ($auth) { warn "AUTH requested\n" if ($mailcfg{debug} > 4); # reduce wanted methods to those supported my @methods = grep {$esmtp{'AUTH'}=~/(^|\s)$_(\s|$)/i} grep {$auth_support =~ /(^|\s)$_(\s|$)/i} grep /\S/, split(/\s+/, $auth->{method}); if (@methods) { # try to authenticate if (exists $auth->{pass}) { $auth->{password} = $auth->{pass}; } my $method = uc $methods[0]; _require_base64() || fail("Could not use MIME::Base64 module required for authentication"); if ($method eq "LOGIN") { print STDERR "Trying AUTH LOGIN\n" if ($mailcfg{debug} > 9); socket_write("AUTH LOGIN$CRLF") || return fail("send AUTH LOGIN failed (lost connection?)"); socket_read() || return fail("AUTH LOGIN failed: $server_reply"); socket_write(encode_base64($auth->{user},$CRLF)) || return fail("send LOGIN username failed (lost connection?)"); socket_read() || return fail("LOGIN username failed: $server_reply"); socket_write(encode_base64($auth->{password},$CRLF)) || return fail("send LOGIN password failed (lost connection?)"); socket_read() || return fail("LOGIN password failed: $server_reply"); } elsif ($method eq "PLAIN") { warn "Trying AUTH PLAIN\n" if ($mailcfg{debug} > 9); socket_write( "AUTH PLAIN " . encode_base64(join("\0", $auth->{user}, $auth->{user}, $auth->{password}), $CRLF) ) || return fail("send AUTH PLAIN failed (lost connection?)"); socket_read() || return fail("AUTH PLAIN failed: $server_reply"); } elsif ($method eq "CRAM-MD5") { _require_md5() || fail("Could not use Digest::MD5 module required for authentication"); warn "Trying AUTH CRAM-MD5\n" if ($mailcfg{debug} > 9); socket_write("AUTH CRAM-MD5$CRLF") || return fail("send CRAM-MD5 failed (lost connection?)"); my $challenge = socket_read() || return fail("AUTH CRAM-MD5 failed: $server_reply"); $challenge =~ s/^\d+\s+//; my $response = _hmac_md5($auth->{password}, decode_base64($challenge)); socket_write(encode_base64("$auth->{user} $response", $CRLF)) || return fail("AUTH CRAM-MD5 failed: $server_reply"); socket_read() || return fail("AUTH CRAM-MD5 failed: $server_reply"); } elsif ($method eq "DIGEST-MD5") { _require_md5() || fail("Could not use Digest::MD5 module required for authentication"); warn "Trying AUTH DIGEST-MD5\n" if ($mailcfg{debug} > 9); socket_write("AUTH DIGEST-MD5$CRLF") || return fail("send CRAM-MD5 failed (lost connection?)"); my $challenge = socket_read() || return fail("AUTH DIGEST-MD5 failed: $server_reply"); $challenge =~ s/^\d+\s+//; $challenge =~ s/[\r\n]+$//; warn "\nCHALLENGE=", decode_base64($challenge), "\n" if ($mailcfg{debug} > 10); my $response = _digest_md5($auth->{user}, $auth->{password}, decode_base64($challenge), $auth->{realm}); warn "\nRESPONSE=$response\n" if ($mailcfg{debug} > 10); socket_write(encode_base64($response, ""), $CRLF) || return fail("AUTH DIGEST-MD5 failed: $server_reply"); my $status = socket_read() || return fail("AUTH DIGEST-MD5 failed: $server_reply"); if ($status =~ /^3/) { socket_write($CRLF) || return fail("AUTH DIGEST-MD5 failed: $server_reply"); socket_read() || return fail("AUTH DIGEST-MD5 failed: $server_reply"); } } else { return fail("$method not supported (and wrongly advertised as supported by this silly module)\n"); } $log .= "AUTH $method succeeded as user $auth->{user}\n"; } else { $esmtp{'AUTH'} =~ s/(^\s+|\s+$)//g; # cleanup for printig it below if ($auth->{required}) { return fail("Required AUTH method '$auth->{method}' not supported. " ."(Server supports '$esmtp{'AUTH'}'. Module supports: '$auth_support')"); } else { warn "No common authentication method! Requested: '$auth->{method}'. Server supports '$esmtp{'AUTH'}'. Module supports: '$auth_support'. Skipping authentication\n"; } } } socket_write("MAIL FROM:<$fromaddr>$CRLF") || return fail("send MAIL FROM: error"); socket_read() || return fail("MAIL FROM: error ($_)"); my $to_ok = 0; foreach $to (@recipients) { socket_write("RCPT TO:<$to>$CRLF") || return fail("send RCPT TO: error"); if (socket_read()) { $log .= "To: $to\n"; $to_ok++; } else { $log .= "FAILED To: $to ($server_reply)"; $error .= "Bad recipient <$to>: $server_reply\n"; } } unless ($to_ok) { return fail("No valid recipient"); } # start data part socket_write("DATA$CRLF") || return fail("send DATA error"); socket_read() || return fail("DATA error ($_)"); # print headers foreach $header (keys %mail) { next if $header eq "Message"; $mail{$header} =~ s/\s+$//o; # kill possible trailing garbage socket_write("$header: $mail{$header}$CRLF") || return fail("send $header: error"); }; #- test diconnecting from network here, to see what happens #- print STDERR "DISCONNECT NOW!\n"; #- sleep 4; #- print STDERR "trying to continue, expecting an error... \n"; # send message body (passed as a reference, in case it's big) socket_write($CRLF, \$mail{'Message'}, "$CRLF.$CRLF") || return fail("send message error"); socket_read() || return fail("message transmission error ($_)"); $log .= "\nResult: $_"; # finish socket_write("QUIT$CRLF") || return fail("send QUIT error"); socket_read(); close S; return 1; } # end sub sendmail 1; __END__ =head1 SYNOPSIS use Mail::Sendmail; %mail = ( To => 'you@there.com', From => 'me@here.com', Message => "This is a very short message" ); sendmail(%mail) or die $Mail::Sendmail::error; print "OK. Log says:\n", $Mail::Sendmail::log; =head1 DESCRIPTION Simple platform independent e-mail from your perl script. Only requires Perl 5 and a network connection. Mail::Sendmail takes a hash with the message to send and sends it to your mail server. It is intended to be very easy to setup and use. See also L<"FEATURES"> below, and as usual, read this documentation. There is also a FAQ (see L<"NOTES">). =head1 INSTALLATION =over 4 =item Best C =item Traditional perl Makefile.PL make make test make install =item Manual Copy Sendmail.pm to Mail/ in your Perl lib directory. (eg. c:\Perl\site\lib\Mail\ or /usr/lib/perl5/site_perl/Mail/ or whatever it is on your system. They are listed when you type C< perl -V >) =item ActivePerl's PPM Depending on your PPM version: ppm install --location=http://alma.ch/perl/ppm Mail-Sendmail or ppm install http://alma.ch/perl/ppm/Mail-Sendmail.ppd But this way you don't get a chance to have a look at other files (Changes, Todo, test.pl, ...). =back At the top of Sendmail.pm, set your default SMTP server(s), unless you specify it with each message, or want to use the default (localhost). Install MIME::QuotedPrint. This is not required but strongly recommended. =head1 FEATURES Automatic time zone detection, Date: header, MIME quoted-printable encoding (if MIME::QuotedPrint installed), all of which can be overridden. Bcc: and Cc: support. Allows real names in From:, To: and Cc: fields Doesn't send an X-Mailer: header (unless you do), and allows you to send any header(s) you want. Configurable retries and use of alternate servers if your mail server is down Good plain text error reporting Experimental support for SMTP AUTHentication =head1 LIMITATIONS Headers are not encoded, even if they have accented characters. Since the whole message is in memory, it's not suitable for sending very big attached files. The SMTP server has to be set manually in Sendmail.pm or in your script, unless you have a mail server on localhost. Doesn't work on OpenVMS, I was told. Cannot test this myself. =head1 CONFIGURATION =over 4 =item Default SMTP server(s) This is probably all you want to configure. It is usually done through I<$mailcfg{smtp}>, which you can edit at the top of the Sendmail.pm file. This is a reference to a list of SMTP servers. You can also set it from your script: C Alternatively, you can specify the server in the I<%mail> hash you send from your script, which will do the same thing: C<$mail{smtp} = 'my.mail.server';> A future version will (hopefully) try to set useful defaults for you during the Makefile.PL. =item Other configuration settings See I<%mailcfg> under L<"DETAILS"> below for other configuration options. =back =head1 DETAILS =head2 sendmail() sendmail is the only thing exported to your namespace by default C It takes a hash containing the full message, with keys for all headers and the body, as well as for some specific options. It returns 1 on success or 0 on error, and rewrites C<$Mail::Sendmail::error> and C<$Mail::Sendmail::log>. Keys are NOT case-sensitive. The colon after headers is not necessary. The Body part key can be called 'Body', 'Message' or 'Text'. The SMTP server key can be called 'Smtp' or 'Server'. If the connection to this one fails, the other ones in C<$mailcfg{smtp}> will still be tried. The following headers are added unless you specify them yourself: Mime-Version: 1.0 Content-Type: 'text/plain; charset="iso-8859-1"' Content-Transfer-Encoding: quoted-printable or (if MIME::QuotedPrint not installed) Content-Transfer-Encoding: 8bit Date: [string returned by time_to_date()] If you wish to use an envelope sender address different than the From: address, set C<$mail{Sender}> in your %mail hash. The following are not exported by default, but you can still access them with their full name, or request their export on the use line like in: C =head3 embedding options in your %mail hash The following options can be set in your %mail hash. The corresponding keys will be removed before sending the mail. =over 4 =item $mail{smtp} or $mail{server} The SMTP server to try first. It will be added =item $mail{port} This option will be removed. To use a non-standard port, set it in your server name: $mail{server}='my.smtp.server:2525' will try to connect to port 2525 on server my.smtp.server =item $mail{auth} This must be a reference to a hash containg all your authentication options: $mail{auth} = \%options; or $mail{auth} = {user=>"username", password=>"password", method=>"DIGEST-MD5", required=>0 }; =over =item user username =item pass or password password =item method optional method. compared (stripped down) to available methods. If empty, will try all available. =item required optional. defaults to false. If set to true, no delivery will be attempted if authentication fails. If false or undefined, and authentication fails or is not available, sending is tried without. (different auth for different servers?) =back =back =head2 Mail::Sendmail::time_to_date() convert time ( as from C ) to an RFC 822 compliant string for the Date header. See also L<"%Mail::Sendmail::mailcfg">. =head2 $Mail::Sendmail::error When you don't run with the B<-w> flag, the module sends no errors to STDERR, but puts anything it has to complain about in here. You should probably always check if it says something. =head2 $Mail::Sendmail::log A summary that you could write to a log file after each send =head2 $Mail::Sendmail::address_rx A handy regex to recognize e-mail addresses. A correct regex for valid e-mail addresses was written by one of the judges in the obfuscated Perl contest... :-) It is quite big. This one is an attempt to a reasonable compromise, and should accept all real-world internet style addresses. The domain part is required and comments or characters that would need to be quoted are not supported. Example: $rx = $Mail::Sendmail::address_rx; if (/$rx/) { $address=$1; $user=$2; $domain=$3; } =head2 %Mail::Sendmail::mailcfg This hash contains installation-wide configuration options. You normally edit it once (if ever) in Sendmail.pm and forget about it, but you could also access it from your scripts. For readability, I'll assume you have imported it (with something like C). The keys are not case-sensitive: they are all converted to lowercase before use. Writing C<$mailcfg{Port} = 2525;> is OK: the default $mailcfg{port} (25) will be deleted and replaced with your new value of 2525. =over 4 =item $mailcfg{smtp} C<$mailcfg{smtp} = [qw(localhost my.other.mail.server)];> This is a reference to a list of smtp servers, so if your main server is down, the module tries the next one. If one of your servers uses a special port, add it to the server name with a colon in front, to override the default port (like in my.special.server:2525). Default: localhost. =item $mailcfg{from} C<$mailcfg{from} = 'Mailing script me@mydomain.com';> From address used if you don't supply one in your script. Should not be of type 'user@localhost' since that may not be valid on the recipient's host. Default: undefined. =item $mailcfg{mime} C<$mailcfg{mime} = 1;> Set this to 0 if you don't want any automatic MIME encoding. You normally don't need this, the module should 'Do the right thing' anyway. Default: 1; =item $mailcfg{retries} C<$mailcfg{retries} = 1;> How many times should the connection to the same SMTP server be retried in case of a failure. Default: 1; =item $mailcfg{delay} C<$mailcfg{delay} = 1;> Number of seconds to wait between retries. This delay also happens before trying the next server in the list, if the retries for the current server have been exhausted. For CGI scripts, you want few retries and short delays to return with a results page before the http connection times out. For unattended scripts, you may want to use many retries and long delays to have a good chance of your mail being sent even with temporary failures on your network. Default: 1 (second); =item $mailcfg{tz} C<$mailcfg{tz} = '+0800';> Normally, your time zone is set automatically, from the difference between C and C. This allows you to override automatic detection in cases where your system is confused (such as some Win32 systems in zones which do not use daylight savings time: see Microsoft KB article Q148681) Default: undefined (automatic detection at run-time). =item $mailcfg{port} C<$mailcfg{port} = 25;> Port used when none is specified in the server name. Default: 25. =item $mailcfg{debug} C<$mailcfg{debug} = 0;> Prints stuff to STDERR. Current maximum is 6, which prints the whole SMTP session, except data exceeding 500 bytes. Default: 0; =back =head2 $Mail::Sendmail::VERSION The package version number (you can not import this one) =head2 Configuration variables from previous versions The following global variables were used in version 0.74 for configuration. As from version 0.78_1, they are not supported anymore. Use the I<%mailcfg> hash if you need to access the configuration from your scripts. =over 4 =item $Mail::Sendmail::default_smtp_server =item $Mail::Sendmail::default_smtp_port =item $Mail::Sendmail::default_sender =item $Mail::Sendmail::TZ =item $Mail::Sendmail::connect_retries =item $Mail::Sendmail::retry_delay =item $Mail::Sendmail::use_MIME =back =head1 ANOTHER EXAMPLE use Mail::Sendmail; print "Testing Mail::Sendmail version $Mail::Sendmail::VERSION\n"; print "Default server: $Mail::Sendmail::mailcfg{smtp}->[0]\n"; print "Default sender: $Mail::Sendmail::mailcfg{from}\n"; %mail = ( #To => 'No to field this time, only Bcc and Cc', #From => 'not needed, use default', Bcc => 'Someone , Someone else her@there.com', # only addresses are extracted from Bcc, real names disregarded Cc => 'Yet someone else ', # Cc will appear in the header. (Bcc will not) Subject => 'Test message', 'X-Mailer' => "Mail::Sendmail version $Mail::Sendmail::VERSION", ); $mail{Smtp} = 'special_server.for-this-message-only.domain.com'; $mail{'X-custom'} = 'My custom additionnal header'; $mail{'mESSaGE : '} = "The message key looks terrible, but works."; # cheat on the date: $mail{Date} = Mail::Sendmail::time_to_date( time() - 86400 ); if (sendmail %mail) { print "Mail sent OK.\n" } else { print "Error sending mail: $Mail::Sendmail::error \n" } print "\n\$Mail::Sendmail::log says:\n", $Mail::Sendmail::log; Also see http://alma.ch/perl/Mail-Sendmail-FAQ.html for examples of HTML mail and sending attachments. =head1 CHANGES Main changes since version 0.79: Experimental SMTP AUTH support (LOGIN PLAIN CRAM-MD5 DIGEST-MD5) Fix bug where one refused RCPT TO: would abort everything send EHLO, and parse response Better handling of multi-line responses, and better error-messages Non-conforming line-endings also normalized in headers Now keeps the Sender header if it was used. Previous versions only used it for the MAIL FROM: command and deleted it. See the F file for the full history. If you don't have it because you installed through PPM, you can also find the latest one on F. =head1 NOTES MIME::QuotedPrint is used by default on every message if available. It allows reliable sending of accented characters, and also takes care of too long lines (which can happen in HTML mails). It is available in the MIME-Base64 package at http://www.perl.com/CPAN/modules/by-module/MIME/ or through PPM. Look at http://alma.ch/perl/Mail-Sendmail-FAQ.html for additional info (CGI, examples of sending attachments, HTML mail etc...) You can use this module freely. (Someone complained this is too vague. So, more precisely: do whatever you want with it, but be warned that terrible things will happen to you if you use it badly, like for sending spam, or ...?) Thanks to the many users who sent me feedback, bug reports, suggestions, etc. And please excuse me if I forgot to answer your mail. I am not always reliabe in answering mail. I intend to set up a mailing list soon. Last revision: 06.02.2003. Latest version should be available on CPAN: F. =head1 AUTHOR Milivoj Ivkovic ("\x40" is "@" of course) =head1 COPYRIGHT Copyright (c) 1998-2017 Milivoj Ivkovic. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut