SendMail.pm -- Perl Module

[ Back To Index ]

Google
 


SendMail.pm 2.09 version is ready now,
click here to have a look. This version supports
MIME format mail, i.e. you can send attachments.

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;
       $sender		     = "Sender <sender@domain.com>";
       $subject		     = "Subject	of the mail.";
       $recipient	     = "Recipient <recipient@domain.com>";
       $recipient2	     = "Recipient 2 <recipient2@domain.com>";
       @recipients	     = ($recipient, $recipient2);
       $administrator	     = "Administrator <admin@domain.com>";
       $administrator2	     = "Administrator 2	<admin2@domain.com>";
       $replyto		     = $sender;
       $replyto2	     = $recipient;
       @replytos	     = ($replyto, $replyto2);
       $header		     = "X-Mailer";
       $headervalue	     = "Perl SendMail Module 1.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->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);

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

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

       $obj->setMailBody($mailbodydata);

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

       $obj->reset();

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

     Form Page
     http://www.tneoh.zoneit.com/perl/SendMail/form.html

     Perl CGI Script
     http://www.tneoh.zoneit.com/perl/SendMail/SendMail.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
     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 "<user@domain.com>" format.
     1.05->1.06 sendToServer() subroutine should send "\r\n"
     instead of "\n" only to the server. Sending only "\n" to
     the SMTP server, will cause errors for SMTP server on
     Windows platform. 
     1.06->1.07 Calling eof() to check the opened socket, else
     it will cause an error in ActivePerl5.6.
     1.07->1.08 After sending the maildata, supposed to be 
     "\r\n" instead of just "\n".
     1.08->1.09 Better approach to fix bare LF problem.


CREDITS
     laurens van alphen

     Dag Řien

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

     Arjan Woerden

     Jeff Graves

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

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 1.09   04 March 2003

SEE ALSO
     Socket.pm

The CGI Resource
                  Index

Rate
           this Script @ The CGI Resource Index


[ Back To Index ]