SendMail(3)    User Contributed Perl Documentation    SendMail(3)



NAME
       SendMail -- This is a perl module which is using Socket to
       connect the SMTP port to send mails.

SYNOPSIS
	 use SendMail;

	 $smtpserver	       = "mail.server.com";
	 $smtpport	       = 25;
	 $userid	       = "authuserid";
	 $password	       = "authpassword";
	 $sender	       = "Sender ";
	 $subject	       = "Subject of the mail.";
	 $recipient	       = "Recipient ";
	 $recipient2	       = "Recipient 2 ";
	 @recipients	       = ($recipient, $recipient2);
	 $administrator	       = "Administrator ";
	 $administrator2       = "Administrator 2 ";
	 $replyto	       = $sender;
	 $replyto2	       = $recipient;
	 @replytos	       = ($replyto, $replyto2);
	 $header	       = "X-Mailer";
	 $headervalue	       = "Perl SendMail Module 2.09";
	 $mailbodydata	       = "This is a testing mail.";

	 $obj = new SendMail();
	 $obj = new SendMail($smtpserver);
	 $obj = new SendMail($smtpserver, $smtpport);

	 $obj->setDebug($obj->ON);
	 $obj->setDebug($obj->OFF);

	 $obj->setAuth($obj->AUTHLOGIN, $userid, $password);
	 $obj->setAuth($obj->AUTHPLAIN, $userid, $password);

	 $obj->From($sender);

	 $obj->Subject($subject);

	 $obj->To($recipient);
	 $obj->To($recipient, $recipient2);
	 $obj->To(@recipients);

	 $obj->Cc($recipient);
	 $obj->Cc($recipient, $recipient2);
	 $obj->Cc(@recipients);

	 $obj->Bcc($recipient);
	 $obj->Bcc($recipient, $recipient2);
	 $obj->Bcc(@recipients);

	 $obj->ErrorsTo($administrator);
	 $obj->ErrorsTo($administrator, $administrator2);
	 $obj->ErrorsTo(@administrators);



2003-03-04		   perl v5.6.0				1





SendMail::dvlp:UserdConSendMail::dvlp::SendMail-2.09::SendMail(3)


	 $obj->ReplyTo($replyto);
	 $obj->ReplyTo($replyto, $replyto2);
	 $obj->ReplyTo(@replytos);

	 $obj->setMailHeader($header, $headervalue);

	 $obj->setMailBody($mailbodydata);

	 $obj->Attach($file);
	 $obj->Attach($file, \$filedata);
	 $obj->Attach($file, \*FILEHANDLE);
	 $obj->Attach($file, new IO::File("filename", "r"));

	 $obj->Inline($file);
	 $obj->Inline($file, \$filedata);
	 $obj->Inline($file, \*FILEHANDLE);
	 $obj->Inline($file, new IO::File("filename", "r"));

	 if ($obj->sendMail() != 0) {
	   print $obj->{'error'}."\n";
	 }

	 $obj->clearTo();
	 $obj->clearBcc();
	 $obj->clearCc();
	 $obj->clearAttach();

	 $obj->reset();


EXAMPLE
       http://www.tneoh.zoneit.com/perl/SendMail/testSendMail.pl

DESCRIPTION
       This module is written so that user can easily use it to
       send mailing list.  Please do not abuse it.

       And it can be used in any perl script to send a mail
       similar to sending mail by using /usr/lib/sendmail
       program.

       I have tested this module on Unix and Windows platforms,
       it works fine.  Of course you need perl version 5. With
       the example script, testSendMail.pl, you can simply a
       testing on it.

       Errors, comments or questions are welcome.

CHANGES
       1.00->1.01 Recipients with email address contains a "-" in
       the hostname, will be able to receive the email now.

       1.01->1.02 Module now not only expecting one line reply
       from the server, it can receive multiple lines until the



2003-03-04		   perl v5.6.0				2





SendMail::dvlp:UserdConSendMail::dvlp::SendMail-2.09::SendMail(3)


       server waiting for next command.

       1.02->1.03 Repeat declaration of "$currEmail" will give an
       error in NT system.

       1.03->1.04 Email addresses are enclosed in < and > after
       "MAIL FROM" and "RCPT TO" commands.(RFC821) For Microsoft
       Exchange 4, email addresses not enclosed in < and > will
       get an error from the system.

       1.04->1.05 getEmailAddress() subroutine should accept
       email address in just "" format.

       1.05->2.00b Simple MIME supported. attach(), Attach() and
       Inline() subroutines added.

       2.00b->2.00 Attach() and Inline() supports for filehandle
       which is easier for users who are using CGI.pm. Prototypes
       are added. And we send "\r\n" to the SMTP server instead
       of only "\n".

       2.00->2.01 After sending the maildata, supposed to be
       "\r\n" instead of just "\n".

       2.01->2.02 Calling eof() to check the opened socket, else
       it will cause an error in ActivePerl5.6.

       2.02->2.03 Change all EOL to "\r\n", instead of just "\n".

       2.03->2.04 Only Base64 encoding is being used, no more
       using Quoted Print. And import() has been taken out for
       Sys::Hostname as it has been deprecated. Giving more hints
       in "no host" error message.

       2.04->2.05 clearTo(), clearCc() and clearBcc() are added
       to allow clearing the recipient email addresses without
       reset the whole email information, eg. body, subject and
       etc. Simple SMTP AUTH is supported.

       2.05->2.06 Some values were not initialized.

       2.06->2.07 The clearXXX() functions, eg. clearTo(), did
       not work well when sending multiple emails. The list was
       not cleared properly. For example, the To: field would be
       left with a "ARRAY@localhost.domain.com (82477472)," in
       it. clearAttach() is added.  And EHLO is used first to
       support SMTP AUTH, because some of the MTA is looking for
       EHLO first.

       2.07->2.08 Bare LF error occurred when no attachment.

       2.08->2.09 Better fix for LF problem.





2003-03-04		   perl v5.6.0				3





SendMail::dvlp:UserdConSendMail::dvlp::SendMail-2.09::SendMail(3)


CREDITS
       laurens van alphen

       Dag Oien

       Juliano, Sylvia, CON, OASD(HA)/TMA

       Tony Simopoulos

       Jeff Graves

       Pisciotta, Steve

       Phill Crow

       Mark Grennan

       Bill Friend

SOURCE
       http://www.tneoh.zoneit.com/perl/SendMail/SendMail.pm

AUTHOR
       Simon Tneoh Chee-Boon	tneohcb@pc.jaring.my

       Copyright (c) 1998-2003 Simon Tneoh Chee-Boon. All rights
       reserved.  This program is free software; you can
       redistribute it and/or modify it under the same terms as
       Perl itself.

VERSION
       Version 2.09   04 March 2003

SEE ALSO
       Socket.pm, MIME::Base64.pm, MIME::QuotedPrint.pm






















2003-03-04		   perl v5.6.0				4