Moved to subdirectory phpmailer
authormartin <martin>
Fri, 24 May 2002 06:46:54 +0000 (06:46 +0000)
committermartin <martin>
Fri, 24 May 2002 06:46:54 +0000 (06:46 +0000)
lib/class.phpmailer.php [deleted file]
lib/class.smtp.php [deleted file]

diff --git a/lib/class.phpmailer.php b/lib/class.phpmailer.php
deleted file mode 100644 (file)
index 5986111..0000000
+++ /dev/null
@@ -1,984 +0,0 @@
-<?php
-////////////////////////////////////////////////////
-// phpmailer - PHP email class
-//
-// Version 1.25, Created 07/02/2001
-//
-// Class for sending email using either
-// sendmail, PHP mail(), or SMTP.  Methods are
-// based upon the standard AspEmail(tm) classes.
-//
-// Author: Brent R. Matzelle <bmatzelle@yahoo.com>
-//
-// License: LGPL, see LICENSE
-////////////////////////////////////////////////////
-
-/**
- * phpmailer - PHP email transport class
- * @author Brent R. Matzelle
- */
-class phpmailer
-{
-   /////////////////////////////////////////////////
-   // PUBLIC VARIABLES
-   /////////////////////////////////////////////////
-
-   /**
-    * Email priority (1 = High, 3 = Normal, 5 = low). Default value is 3.
-    * @public
-    * @type int
-    */
-   var $Priority         = 3;
-
-   /**
-    * Sets the CharSet of the message. Default value is "iso-8859-1".
-    * @public
-    * @type string
-    */
-   var $CharSet          = "iso-8859-1";
-
-   /**
-    * Sets the Content-type of the message. Default value is "text/plain".
-    * @public
-    * @type string
-    */
-   var $ContentType      = "text/plain";
-
-   /**
-    * Sets the Encoding of the message. Options for this are "8bit" (default),
-    * "7bit", "binary", "base64", and "quoted-printable".
-    * @public
-    * @type string
-    */
-   var $Encoding         = "8bit";
-
-   /**
-    * Holds the most recent mailer error message. Default value is "".
-    * @public
-    * @type string
-    */
-   var $ErrorInfo        = "";
-
-   /**
-    * Sets the From email of the message. Default value is "root@localhost".
-    * @public
-    * @type string
-    */
-   var $From             = "root@localhost";
-
-   /**
-    * Sets the From name of the message. Default value is "Root User".
-    * @public
-    * @type string
-    */
-   var $FromName         = "Root User";
-
-   /**
-    * Sets the Sender email of the message. If not empty, will be sent via -f to sendmail
-    * or as 'MAIL FROM' in smtp mode. Default value is "".
-    * @public
-    * @type string
-    */
-   var $Sender           = "";
-
-   /**
-    * Sets the Subject of the message. Default value is "".
-    * @public
-    * @type string
-    */
-   var $Subject          = "";
-
-   /**
-    * Sets the Body of the message. Default value is "".
-    * @public
-    * @type string
-    */
-   var $Body             = "";
-
-   /**
-    * Sets word wrapping on the message. Default value is false (off).
-    * @public
-    * @type string
-    */
-   var $WordWrap         = false;
-
-   /**
-    * Method to send mail: ("mail", "sendmail", or "smtp").
-    * Default value is "mail".
-    * @public
-    * @type string
-    */
-   var $Mailer           = "mail";
-
-   /**
-    * Sets the path of the sendmail program. Default value is
-    * "/usr/sbin/sendmail".
-    * @public
-    * @type string
-    */
-   var $Sendmail         = "/usr/sbin/sendmail";
-
-   /**
-    *  Turns Microsoft mail client headers on and off. Default value is false (off).
-    *  @public
-    *  @type bool
-    */
-   var $UseMSMailHeaders = false;
-
-   /**
-    *  Holds phpmailer version.
-    *  @public
-    *  @type string
-    */
-   //var $Version       = "phpmailer [version 1.25]";
-   var $Version       = "Moodle [phpmailer 1.25]";
-
-
-   /////////////////////////////////////////////////
-   // SMTP VARIABLES
-   /////////////////////////////////////////////////
-
-   /**
-    *  Sets the SMTP host. Default value is "localhost".
-    *  @public
-    *  @type string
-    */
-   var $Host        = "localhost";
-
-   /**
-    *  Sets the SMTP server port. Default value is 25.
-    *  @public
-    *  @type int
-    */
-   var $Port        = 25;
-
-   /**
-    *  Sets the CharSet of the message. Default value is "localhost.localdomain".
-    *  @public
-    *  @type string
-    */
-   var $Helo        = "localhost.localdomain";
-
-   /**
-    *  Sets the SMTP server timeout. Default value is 10.
-    *  @public
-    *  @type int
-    */
-   var $Timeout     = 10; // Socket timeout in sec.
-
-   /**
-    *  Sets SMTP class debugging on or off. Default value is false (off).
-    *  @public
-    *  @type bool
-    */
-   var $SMTPDebug   = false;
-
-
-   /////////////////////////////////////////////////
-   // PRIVATE VARIABLES
-   /////////////////////////////////////////////////
-
-   /**
-    *  Holds all "To" addresses.
-    *  @type array
-    */
-   var $to            = array();
-
-   /**
-    *  Holds all "CC" addresses.
-    *  @type array
-    */
-   var $cc            = array();
-
-   /**
-    *  Holds all "BCC" addresses.
-    *  @type array
-    */
-   var $bcc           = array();
-
-   /**
-    *  Holds all "Reply-To" addresses.
-    *  @type array
-    */
-   var $ReplyTo       = array();
-
-   /**
-    *  Holds all attachments.
-    *  @type array
-    */
-   var $attachment    = array();
-
-   /**
-    *  Holds all custom headers.
-    *  @type array
-    */
-   var $CustomHeader  = array();
-
-   /**
-    *  Holds the message boundary. Default is false.
-    *  @type string
-    */
-   var $boundary      = false;
-
-   /////////////////////////////////////////////////
-   // VARIABLE METHODS
-   /////////////////////////////////////////////////
-
-   /**
-    * Sets message type to HTML.  Returns void.
-    * @public
-    * @returns void
-    */
-   function IsHTML($bool) {
-      if($bool == true)
-         $this->ContentType = "text/html";
-      else
-         $this->ContentType = "text/plain";
-   }
-
-   /**
-    * Sets Mailer to use SMTP.  Returns void.
-    * @public
-    * @returns void
-    */
-   function IsSMTP() {
-      $this->Mailer = "smtp";
-   }
-
-   /**
-    * Sets Mailer to use PHP mail() function.  Returns void.
-    * @public
-    * @returns void
-    */
-   function IsMail() {
-      $this->Mailer = "mail";
-   }
-
-   /**
-    * Sets Mailer to use $Sendmail program.  Returns void.
-    * @public
-    * @returns void
-    */
-   function IsSendmail() {
-      $this->Mailer = "sendmail";
-   }
-
-   /**
-    * Sets Mailer to use qmail MTA.  Returns void.
-    * @public
-    * @returns void
-    */
-   function IsQmail() {
-      //$this->Sendmail = "/var/qmail/bin/qmail-inject";
-      $this->Sendmail = "/var/qmail/bin/sendmail";
-      $this->Mailer = "sendmail";
-   }
-
-
-   /////////////////////////////////////////////////
-   // RECIPIENT METHODS
-   /////////////////////////////////////////////////
-
-   /**
-    * Adds a "to" address.  Returns void.
-    * @public
-    * @returns void
-    */
-   function AddAddress($address, $name = "") {
-      $cur = count($this->to);
-      $this->to[$cur][0] = trim($address);
-      $this->to[$cur][1] = $name;
-   }
-
-   /**
-    * Adds a "Cc" address. Returns void.
-    * @public
-    * @returns void
-    */
-   function AddCC($address, $name = "") {
-      $cur = count($this->cc);
-      $this->cc[$cur][0] = trim($address);
-      $this->cc[$cur][1] = $name;
-   }
-
-   /**
-    * Adds a "Bcc" address. Note: this function works 
-    * with the SMTP mailer on win32, not with the "mail" 
-    * mailer.  This is a PHP bug that has been submitted 
-    * on the Zend web site. The UNIX version of PHP 
-    * functions correctly. 
-    * Returns void.
-    * @public
-    * @returns void
-    */
-   function AddBCC($address, $name = "") {
-      $cur = count($this->bcc);
-      $this->bcc[$cur][0] = trim($address);
-      $this->bcc[$cur][1] = $name;
-   }
-
-   /**
-    * Adds a "Reply-to" address.  Returns void.
-    * @public
-    * @returns void
-    */
-   function AddReplyTo($address, $name = "") {
-      $cur = count($this->ReplyTo);
-      $this->ReplyTo[$cur][0] = trim($address);
-      $this->ReplyTo[$cur][1] = $name;
-   }
-
-
-   /////////////////////////////////////////////////
-   // MAIL SENDING METHODS
-   /////////////////////////////////////////////////
-
-   /**
-    * Creates message and assigns Mailer. If the message is 
-    * not sent successfully then it returns false.  Returns bool.
-    * @public
-    * @returns bool
-    */
-   function Send() {
-      if(count($this->to) < 1)
-      {
-         $this->error_handler("You must provide at least one recipient email address");
-         return false;
-      }
-
-      $header = $this->create_header();
-      if(!$body = $this->create_body())
-         return false;
-
-      // Choose the mailer
-      if($this->Mailer == "sendmail")
-      {
-         if(!$this->sendmail_send($header, $body))
-            return false;
-      }
-      elseif($this->Mailer == "mail")
-      {
-         if(!$this->mail_send($header, $body))
-            return false;
-      }
-      elseif($this->Mailer == "smtp")
-      {
-         if(!$this->smtp_send($header, $body))
-            return false;
-      }
-      else
-      {
-         $this->error_handler(sprintf("%s mailer is not supported", $this->Mailer));
-         return false;
-      }
-
-      return true;
-   }
-
-   /**
-    * Sends mail using the $Sendmail program.  Returns bool.
-    * @private
-    * @returns bool
-    */
-   function sendmail_send($header, $body) {
-      if ($this->Sender != "")
-         $sendmail = sprintf("%s -f %s -t", $this->Sendmail, $this->Sender);
-      else
-         $sendmail = sprintf("%s -t", $this->Sendmail);
-
-      if(!@$mail = popen($sendmail, "w"))
-      {
-         $this->error_handler(sprintf("Could not execute %s", $this->Sendmail));
-         return false;
-      }
-
-      fputs($mail, $header);
-      fputs($mail, $body);
-      pclose($mail);
-
-      return true;
-   }
-
-   /**
-    * Sends mail using the PHP mail() function.  Returns bool.
-    * @private
-    * @returns bool
-    */
-   function mail_send($header, $body) {
-      //$to = substr($this->addr_append("To", $this->to), 4, -2);
-
-      // Cannot add Bcc's to the $to
-      $to = $this->to[0][0]; // no extra comma
-      for($i = 1; $i < count($this->to); $i++)
-         $to .= sprintf(",%s", $this->to[$i][0]);
-
-      if ($this->Sender != "" && PHP_VERSION >= "4.0")
-      {
-         $old_from = ini_get("sendmail_from");
-         ini_set("sendmail_from", $this->Sender);
-      }
-
-      if ($this->Sender != "" && PHP_VERSION >= "4.0.5")
-      {
-         // The fifth parameter to mail is only available in PHP >= 4.0.5
-         $params = sprintf("-f %s", $this->Sender);
-         $rt = @mail($to, $this->Subject, $body, $header, $params);
-      }
-      else
-      {
-         $rt = @mail($to, $this->Subject, $body, $header);
-      }
-
-      if (isset($old_from))
-         ini_set("sendmail_from", $old_from);
-
-      if(!$rt)
-      {
-         $this->error_handler("Could not instantiate mail()");
-         return false;
-      }
-
-      return true;
-   }
-
-   /**
-    * Sends mail via SMTP using PhpSMTP (Author:
-    * Chris Ryan).  Returns bool.
-    * @private
-    * @returns bool
-    */
-   function smtp_send($header, $body) {
-      // Include SMTP class code, but not twice
-      //include_once("class.smtp.php"); // Load code only if asked
-
-      $smtp = new SMTP;
-      $smtp->do_debug = $this->SMTPDebug;
-
-      // Try to connect to all SMTP servers
-      $hosts = explode(";", $this->Host);
-      $index = 0;
-      $connection = false;
-
-      // Retry while there is no connection
-      while($index < count($hosts) && $connection == false)
-      {
-         if($smtp->Connect($hosts[$index], $this->Port, $this->Timeout))
-            $connection = true;
-         //printf("%s host could not connect<br>", $hosts[$index]); //debug only
-         $index++;
-      }
-      if(!$connection)
-      {
-         $this->error_handler("SMTP Error: could not connect to SMTP host server(s)");
-         return false;
-      }
-
-      $smtp->Hello($this->Helo);
-      if ($this->Sender == "")
-         $smtp->Mail(sprintf("<%s>", $this->From));
-      else
-         $smtp->Mail(sprintf("<%s>", $this->Sender));
-
-      for($i = 0; $i < count($this->to); $i++)
-         $smtp->Recipient(sprintf("<%s>", $this->to[$i][0]));
-      for($i = 0; $i < count($this->cc); $i++)
-         $smtp->Recipient(sprintf("<%s>", $this->cc[$i][0]));
-      for($i = 0; $i < count($this->bcc); $i++)
-         $smtp->Recipient(sprintf("<%s>", $this->bcc[$i][0]));
-
-      if(!$smtp->Data(sprintf("%s%s", $header, $body)))
-      {
-         $this->error_handler("SMTP Error: Data not accepted");
-         return false;
-      }
-      $smtp->Quit();
-
-      return true;
-   }
-
-
-   /////////////////////////////////////////////////
-   // MESSAGE CREATION METHODS
-   /////////////////////////////////////////////////
-
-   /**
-    * Creates recipient headers.  Returns string.
-    * @private
-    * @returns string
-    */
-   function addr_append($type, $addr) {
-      $addr_str = "";
-      $addr_str .= sprintf("%s: %s <%s>", $type, $addr[0][1], $addr[0][0]);
-      if(count($addr) > 1)
-      {
-         for($i = 1; $i < count($addr); $i++)
-         {
-            $addr_str .= sprintf(", %s <%s>", $addr[$i][1], $addr[$i][0]);
-         }
-         $addr_str .= "\r\n";
-      }
-      else
-         $addr_str .= "\r\n";
-
-      return($addr_str);
-   }
-
-   /**
-    * Wraps message for use with mailers that don't
-    * automatically perform wrapping and for quoted-printable.
-    * Original written by philippe.  Returns string.
-    * @private
-    * @returns string
-    */
-   function wordwrap($message, $length, $qp_mode = false) {
-      if ($qp_mode)
-        $soft_break = " =\r\n";
-      else
-        $soft_break = "\r\n";
-
-      $message = $this->fix_eol($message);
-      if (substr($message, -1) == "\r\n")
-        $message = substr($message, 0, -2);
-
-      $line = explode("\r\n", $message);
-      $message = "";
-      for ($i=0 ;$i < count($line); $i++)
-      {
-         $line_part = explode(" ", trim($line[$i]));
-         $buf = "";
-         for ($e = 0; $e<count($line_part); $e++)
-         {
-            $word = $line_part[$e];
-            if ($qp_mode and (strlen($word) > $length))
-            {
-               $space_left = $length - strlen($buf) - 1;
-               if ($e != 0)
-               {
-                  if ($space_left > 20)
-                  {
-                     $len = $space_left;
-                     if (substr($word, $len - 1, 1) == "=")
-                        $len--;
-                     elseif (substr($word, $len - 2, 1) == "=")
-                        $len -= 2;
-                     $part = substr($word, 0, $len);
-                     $word = substr($word, $len);
-                     $buf .= " " . $part;
-                     $message .= $buf . "=\r\n";
-                  }
-                  else
-                  {
-                     $message .= $buf . $soft_break;
-                  }
-                  $buf = "";
-               }
-               while (strlen($word) > 0)
-               {
-                  $len = $length;
-                  if (substr($word, $len - 1, 1) == "=")
-                     $len--;
-                  elseif (substr($word, $len - 2, 1) == "=")
-                     $len -= 2;
-                  $part = substr($word, 0, $len);
-                  $word = substr($word, $len);
-
-                  if (strlen($word) > 0)
-                     $message .= $part . "=\r\n";
-                  else
-                     $buf = $part;
-               }
-            }
-            else
-            {
-               $buf_o = $buf;
-               if ($e == 0)
-                  $buf .= $word;
-               else
-                  $buf .= " " . $word;
-               if (strlen($buf) > $length and $buf_o != "")
-               {
-                  $message .= $buf_o . $soft_break;
-                  $buf = $word;
-               }
-            }
-         }
-         $message .= $buf . "\r\n";
-      }
-
-      return ($message);
-   }
-
-   /**
-    * Assembles message header.  Returns a string if successful
-    * or false if unsuccessful.
-    * @private
-    * @returns string
-    */
-   function create_header() {
-      $header = array();
-      $header[] = sprintf("Date: %s\r\n", $this->rfc_date());
-
-      // To be created automatically by mail()
-      if($this->Mailer != "mail")
-         $header[] = $this->addr_append("To", $this->to);
-
-      $header[] = sprintf("From: %s <%s>\r\n", $this->FromName, trim($this->From));
-      if(count($this->cc) > 0)
-         $header[] = $this->addr_append("Cc", $this->cc);
-
-      // sendmail and mail() extract Bcc from the header before sending
-      if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
-         $header[] = $this->addr_append("Bcc", $this->bcc);
-
-      if(count($this->ReplyTo) > 0)
-         $header[] = $this->addr_append("Reply-to", $this->ReplyTo);
-
-      // mail() sets the subject itself
-      if($this->Mailer != "mail")
-         $header[] = sprintf("Subject: %s\r\n", trim($this->Subject));
-
-      $header[] = sprintf("X-Priority: %d\r\n", $this->Priority);
-      $header[] = sprintf("X-Mailer: %s\r\n", $this->Version);
-      $header[] = sprintf("Return-Path: %s\r\n", trim($this->From));
-
-      // Add custom headers
-      for($index = 0; $index < count($this->CustomHeader); $index++)
-         $header[] = sprintf("%s\r\n", $this->CustomHeader[$index]);
-
-      if($this->UseMSMailHeaders)
-         $header[] = $this->AddMSMailHeaders();
-
-      // Add all attachments
-      if(count($this->attachment) > 0)
-      {
-         // Set message boundary
-         $this->boundary = "_b" . md5(uniqid(time()));
-
-         $header[] = sprintf("Content-Type: Multipart/Mixed; charset = \"%s\";\r\n", $this->CharSet);
-         $header[] = sprintf(" boundary=\"Boundary-=%s\"\r\n", $this->boundary);
-      }
-      else
-      {
-         $header[] = sprintf("Content-Transfer-Encoding: %s\r\n", $this->Encoding);
-         $header[] = sprintf("Content-Type: %s; charset = \"%s\";\r\n", $this->ContentType, $this->CharSet);
-      }
-
-      $header[] = "MIME-Version: 1.0\r\n";
-
-      return(join("", $header));
-   }
-
-   /**
-    * Assembles the message body.  Returns a string if successful
-    * or false if unsuccessful.
-    * @private
-    * @returns string
-    */
-   function create_body() {
-      // wordwrap the message body if set
-      if($this->WordWrap)
-         $this->Body = $this->wordwrap($this->Body, $this->WordWrap);
-
-      $this->Body = $this->encode_string($this->Body, $this->Encoding);
-
-      if(count($this->attachment) > 0)
-      {
-         if(!$body = $this->attach_all())
-            return false;
-      }
-      else
-         $body = $this->Body;
-
-      return($body);
-   }
-
-
-   /////////////////////////////////////////////////
-   // ATTACHMENT METHODS
-   /////////////////////////////////////////////////
-
-   /**
-    * Checks if attachment is valid and then adds 
-    * the attachment to the list. 
-    * Returns false if the file was not found.
-    * @public
-    * @returns bool
-    */
-   function AddAttachment($path, $name = "", $encoding = "base64", $type = "application/octet-stream") {
-      if(!@is_file($path))
-      {
-         $this->error_handler(sprintf("Could not find %s file on filesystem", $path));
-         return false;
-      }
-
-      $filename = basename($path);
-      if($name == "")
-         $name = $filename;
-
-      // Append to $attachment array
-      $cur = count($this->attachment);
-      $this->attachment[$cur][0] = $path;
-      $this->attachment[$cur][1] = $filename;
-      $this->attachment[$cur][2] = $name;
-      $this->attachment[$cur][3] = $encoding;
-      $this->attachment[$cur][4] = $type;
-
-      return true;
-   }
-
-   /**
-    * Attaches text and binary attachments to body.  Returns a
-    * string if successful or false if unsuccessful.
-    * @private
-    * @returns string
-    */
-   function attach_all() {
-      // Return text of body
-      $mime = array();
-      $mime[] = "This is a MIME message. If you are reading this text, you\r\n";
-      $mime[] = "might want to consider changing to a mail reader that\r\n";
-      $mime[] = "understands how to properly display MIME multipart messages.\r\n\r\n";
-      $mime[] = sprintf("--Boundary-=%s\r\n", $this->boundary);
-      $mime[] = sprintf("Content-Type: %s; charset = \"%s\";\r\n", $this->ContentType, $this->CharSet);
-      $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);
-      $mime[] = sprintf("%s\r\n", $this->Body);
-
-      // Add all attachments
-      for($i = 0; $i < count($this->attachment); $i++)
-      {
-         $path = $this->attachment[$i][0];
-         $filename = $this->attachment[$i][1];
-         $name = $this->attachment[$i][2];
-         $encoding = $this->attachment[$i][3];
-         $type = $this->attachment[$i][4];
-         $mime[] = sprintf("--Boundary-=%s\r\n", $this->boundary);
-         $mime[] = sprintf("Content-Type: %s;\r\n", $type);
-         $mime[] = sprintf("name=\"%s\"\r\n", $name);
-         $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n", $encoding);
-         $mime[] = sprintf("Content-Disposition: attachment; filename=\"%s\"\r\n\r\n", $name);
-         if(!$mime[] = sprintf("%s\r\n\r\n", $this->encode_file($path, $encoding)))
-            return false;
-      }
-      $mime[] = sprintf("\r\n--Boundary-=%s--\r\n", $this->boundary);
-
-      return(join("", $mime));
-   }
-
-   /**
-    * Encodes attachment in requested format.  Returns a
-    * string if successful or false if unsuccessful.
-    * @private
-    * @returns string
-    */
-   function encode_file ($path, $encoding = "base64") {
-      if(!@$fd = fopen($path, "r"))
-      {
-         $this->error_handler(sprintf("File Error: Could not open file %s", $path));
-         return false;
-      }
-      $file = fread($fd, filesize($path));
-      $encoded = $this->encode_string($file, $encoding);
-      fclose($fd);
-
-      return($encoded);
-   }
-
-   /**
-    * Encodes string to requested format. Returns a
-    * string if successful or false if unsuccessful.
-    * @private
-    * @returns string
-    */
-   function encode_string ($str, $encoding = "base64") {
-      switch(strtolower($encoding)) {
-         case "base64":
-            // chunk_split is found in PHP >= 3.0.6
-            $encoded = chunk_split(base64_encode($str));
-            break;
-
-         case "7bit":
-         case "8bit":
-            $encoded = $this->fix_eol($str);
-            if (substr($encoded, -2) != "\r\n")
-               $encoded .= "\r\n";
-            break;
-
-         case "binary":
-            $encoded = $str;
-            break;
-
-         case "quoted-printable":
-            $encoded = $this->encode_qp($str);
-            break;
-
-         default:
-            $this->error_handler(sprintf("Unknown encoding: %s", $encoding));
-            return false;
-      }
-      return($encoded);
-   }
-
-   /**
-    * Encode string to quoted-printable.  Returns a string.
-    * @private
-    * @returns string
-    */
-   function encode_qp ($str) {
-      $encoded = $this->fix_eol($str);
-      if (substr($encoded, -2) != "\r\n")
-         $encoded .= "\r\n";
-
-      // Replace every high ascii, control and = characters
-      $encoded = preg_replace("/([\001-\010\013\014\016-\037\075\177-\377])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
-      // Replace every spaces and tabs when it's the last character on a line
-      $encoded = preg_replace("/([\011\040])\r\n/e", "'='.sprintf('%02X', ord('\\1')).'\r\n'", $encoded);
-
-      // Maximum line length of 76 characters before CRLF (74 + space + '=')
-      $encoded = $this->WordWrap($encoded, 74, true);
-
-      return $encoded;
-   }
-
-   /////////////////////////////////////////////////
-   // MESSAGE RESET METHODS
-   /////////////////////////////////////////////////
-
-   /**
-    * Clears all recipients assigned in the TO array.  Returns void.
-    * @public
-    * @returns void
-    */
-   function ClearAddresses() {
-      $this->to = array();
-   }
-
-   /**
-    * Clears all recipients assigned in the CC array.  Returns void.
-    * @public
-    * @returns void
-    */
-   function ClearCCs() {
-      $this->cc = array();
-   }
-
-   /**
-    * Clears all recipients assigned in the BCC array.  Returns void.
-    * @public
-    * @returns void
-    */
-   function ClearBCCs() {
-      $this->bcc = array();
-   }
-
-   /**
-    * Clears all recipients assigned in the ReplyTo array.  Returns void.
-    * @public
-    * @returns void
-    */
-   function ClearReplyTos() {
-      $this->ReplyTo = array();
-   }
-
-   /**
-    * Clears all recipients assigned in the TO, CC and BCC
-    * array.  Returns void.
-    * @public
-    * @returns void
-    */
-   function ClearAllRecipients() {
-      $this->to = array();
-      $this->cc = array();
-      $this->bcc = array();
-   }
-
-   /**
-    * Clears all previously set attachments.  Returns void.
-    * @public
-    * @returns void
-    */
-   function ClearAttachments() {
-      $this->attachment = array();
-   }
-
-   /**
-    * Clears all custom headers.  Returns void.
-    * @public
-    * @returns void
-    */
-   function ClearCustomHeaders() {
-      $this->CustomHeader = array();
-   }
-
-
-   /////////////////////////////////////////////////
-   // MISCELLANEOUS METHODS
-   /////////////////////////////////////////////////
-
-   /**
-    * Adds the error message to the error container.
-    * Returns void.
-    * @private
-    * @returns void
-    */
-   function error_handler($msg) {
-        $this->ErrorInfo = $msg;
-   }
-   
-   /**
-    * Returns the proper RFC 822 formatted date. Returns string.
-    * @private
-    * @returns string
-    */
-   function rfc_date() {
-        $tz = date("Z");
-        $tzs = ($tz < 0) ? "-" : "+";
-        $tz = abs($tz);
-        $tz = $tz/36 + $tz % 3600;
-        $date = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
-        return $date;
-   }
-
-   /**
-    * Changes every end of line from CR or LF to CRLF.  Returns string.
-    * @private
-    * @returns string
-    */
-   function fix_eol($str) {
-      $str = str_replace("\r\n", "\n", $str);
-      $str = str_replace("\r", "\n", $str);
-      $str = str_replace("\n", "\r\n", $str);
-      return $str;
-   }
-
-   /**
-    * Adds a custom header.  Returns void.
-    * @public
-    * @returns void
-    */
-   function AddCustomHeader($custom_header) {
-      $this->CustomHeader[] = $custom_header;
-   }
-
-   /**
-    * Adds all the Microsoft message headers.  Returns string.
-    * @private
-    * @returns string
-    */
-   function AddMSMailHeaders() {
-      $MSHeader = "";
-      if($this->Priority == 1)
-         $MSPriority = "High";
-      elseif($this->Priority == 5)
-         $MSPriority = "Low";
-      else
-         $MSPriority = "Medium";
-
-      $MSHeader .= sprintf("X-MSMail-Priority: %s\r\n", $MSPriority);
-      $MSHeader .= sprintf("Importance: %s\r\n", $MSPriority);
-
-      return($MSHeader);
-   }
-
-}
-// End of class
-?>
diff --git a/lib/class.smtp.php b/lib/class.smtp.php
deleted file mode 100644 (file)
index a0ce998..0000000
+++ /dev/null
@@ -1,939 +0,0 @@
-<?php\r
-    /*\r
-     * File: smtp.php\r
-     *\r
-     * Description: Define an SMTP class that can be used to connect\r
-     *              and communicate with any SMTP server. It implements\r
-     *              all the SMTP functions defined in RFC821 except TURN.\r
-     *\r
-     * Creator: Chris Ryan <chris@greatbridge.com>\r
-     * Created: 03/26/2001\r
-     *\r
-     * TODO:\r
-     *     - Move all the duplicate code to a utility function\r
-     *           Most of the functions have the first lines of\r
-     *           code do the same processing. If this can be moved\r
-     *           into a utility function then it would reduce the\r
-     *           overall size of the code significantly.\r
-     */\r
-\r
-    /*\r
-     * STMP is rfc 821 compliant and implements all the rfc 821 SMTP\r
-     * commands except TURN which will always return a not implemented\r
-     * error. SMTP also provides some utility methods for sending mail\r
-     * to an SMTP server.\r
-     */\r
-    class SMTP {\r
-        var $SMTP_PORT = 25; # the default SMTP PORT\r
-        var $CRLF = "\r\n";  # CRLF pair\r
-\r
-        var $smtp_conn;      # the socket to the server\r
-        var $error;          # error if any on the last call\r
-        var $helo_rply;      # the reply the server sent to us for HELO\r
-\r
-        var $do_debug;       # the level of debug to perform\r
-\r
-        /*\r
-         * SMTP()\r
-         *\r
-         * Initialize the class so that the data is in a known state.\r
-         */\r
-        function SMTP() {\r
-            $this->smtp_conn = 0;\r
-            $this->error = null;\r
-            $this->helo_rply = null;\r
-\r
-            $this->do_debug = 0;\r
-        }\r
-\r
-        /************************************************************\r
-         *                    CONNECTION FUNCTIONS                  *\r
-         ***********************************************************/\r
-\r
-        /*\r
-         * Connect($host, $port=0, $tval=30)\r
-         *\r
-         * Connect to the server specified on the port specified.\r
-         * If the port is not specified use the default SMTP_PORT.\r
-         * If tval is specified then a connection will try and be\r
-         * established with the server for that number of seconds.\r
-         * If tval is not specified the default is 30 seconds to\r
-         * try on the connection.\r
-         *\r
-         * SMTP CODE SUCCESS: 220\r
-         * SMTP CODE FAILURE: 421\r
-         */\r
-        function Connect($host,$port=0,$tval=30) {\r
-            # set the error val to null so there is no confusion\r
-            $this->error = null;\r
-\r
-            # make sure we are __not__ connected\r
-            if($this->connected()) {\r
-                # ok we are connected! what should we do?\r
-                # for now we will just give an error saying we\r
-                # are already connected\r
-                $this->error =\r
-                    array("error" => "Already connected to a server");\r
-                return false;\r
-            }\r
-\r
-            if(empty($port)) {\r
-                $port = $this->SMTP_PORT;\r
-            }\r
-\r
-            #connect to the smtp server\r
-            $this->smtp_conn = fsockopen($host,    # the host of the server\r
-                                         $port,    # the port to use\r
-                                         $errno,   # error number if any\r
-                                         $errstr,  # error message if any\r
-                                         $tval);   # give up after ? secs\r
-            # verify we connected properly\r
-            if(empty($this->smtp_conn)) {\r
-                $this->error = array("error" => "Failed to connect to server",\r
-                                     "errno" => $errno,\r
-                                     "errstr" => $errstr);\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": $errstr ($errno)" . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-\r
-            # sometimes the SMTP server takes a little longer to respond\r
-            # so we will give it a longer timeout for the first read\r
-            //if(function_exists("socket_set_timeout"))\r
-            //   socket_set_timeout($this->smtp_conn, 1, 0);\r
-\r
-            # get any announcement stuff\r
-            $announce = $this->get_lines();\r
-\r
-            # set the timeout  of any socket functions at 1/10 of a second\r
-            //if(function_exists("socket_set_timeout"))\r
-            //   socket_set_timeout($this->smtp_conn, 0, 100000);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;\r
-            }\r
-\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * Connected()\r
-         *\r
-         * Returns true if connected to a server otherwise false\r
-         */\r
-        function Connected() {\r
-            if(!empty($this->smtp_conn)) {\r
-                $sock_status = socket_get_status($this->smtp_conn);\r
-                if($sock_status["eof"]) {\r
-                    # hmm this is an odd situation... the socket is\r
-                    # valid but we aren't connected anymore\r
-                    if($this->do_debug >= 1) {\r
-                        echo "SMTP -> NOTICE:" . $this->CRLF .\r
-                             "EOF caught while checking if connected";\r
-                    }\r
-                    $this->Close();\r
-                    return false;\r
-                }\r
-                return true; # everything looks good\r
-            } \r
-            return false;\r
-        }\r
-\r
-        /*\r
-         * Close()\r
-         *\r
-         * Closes the socket and cleans up the state of the class.\r
-         * It is not considered good to use this function without\r
-         * first trying to use QUIT.\r
-         */\r
-        function Close() {\r
-            $this->error = null; # so there is no confusion\r
-            $this->helo_rply = null;\r
-            if(!empty($this->smtp_conn)) { \r
-                # close the connection and cleanup\r
-                fclose($this->smtp_conn);\r
-                $this->smtp_conn = 0;\r
-            }\r
-        }\r
-\r
-\r
-        /**************************************************************\r
-         *                        SMTP COMMANDS                       *\r
-         *************************************************************/\r
-\r
-        /*\r
-         * Data($msg_data)\r
-         *\r
-         * Issues a data command and sends the msg_data to the server\r
-         * finializing the mail transaction. $msg_data is the message\r
-         * that is to be send with the headers. Each header needs to be\r
-         * on a single line followed by a <CRLF> with the message headers\r
-         * and the message body being seperated by and additional <CRLF>.\r
-         *\r
-         * Implements rfc 821: DATA <CRLF>\r
-         *\r
-         * SMTP CODE INTERMEDIATE: 354\r
-         *     [data]\r
-         *     <CRLF>.<CRLF>\r
-         *     SMTP CODE SUCCESS: 250\r
-         *     SMTP CODE FAILURE: 552,554,451,452\r
-         * SMTP CODE FAILURE: 451,554\r
-         * SMTP CODE ERROR  : 500,501,503,421\r
-         */\r
-        function Data($msg_data) {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Data() without being connected");\r
-                return false;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"DATA" . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 354) {\r
-                $this->error =\r
-                    array("error" => "DATA command not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-\r
-            # the server is ready to accept data!\r
-            # according to rfc 821 we should not send more than 1000\r
-            # including the CRLF\r
-            # characters on a single line so we will break the data up\r
-            # into lines by \r and/or \n then if needed we will break\r
-            # each of those into smaller lines to fit within the limit.\r
-            # in addition we will be looking for lines that start with\r
-            # a period '.' and append and additional period '.' to that\r
-            # line. NOTE: this does not count towards are limit.\r
-\r
-            # normalize the line breaks so we know the explode works\r
-            $msg_data = str_replace("\r\n","\n",$msg_data);\r
-            $msg_data = str_replace("\r","\n",$msg_data);\r
-            $lines = explode("\n",$msg_data);\r
-\r
-            # we need to find a good way to determine is headers are\r
-            # in the msg_data or if it is a straight msg body\r
-            # currently I'm assuming rfc 822 definitions of msg headers\r
-            # and if the first field of the first line (':' sperated)\r
-            # does not contain a space then it _should_ be a header\r
-            # and we can process all lines before a blank "" line as\r
-            # headers.\r
-            $field = substr($lines[0],0,strpos($lines[0],":"));\r
-            $in_headers = false;\r
-            if(!empty($field) && !strstr($field," ")) {\r
-                $in_headers = true;\r
-            }\r
-\r
-            $max_line_length = 998; # used below; set here for ease in change\r
-\r
-            while(list(,$line) = @each($lines)) {\r
-                $lines_out = null;\r
-                if($line == "" && $in_headers) {\r
-                    $in_headers = false;\r
-                }\r
-                # ok we need to break this line up into several\r
-                # smaller lines\r
-                while(strlen($line) > $max_line_length) {\r
-                    $pos = strrpos(substr($line,0,$max_line_length)," ");\r
-                    $lines_out[] = substr($line,0,$pos);\r
-                    $line = substr($line,$pos + 1);\r
-                    # if we are processing headers we need to\r
-                    # add a LWSP-char to the front of the new line\r
-                    # rfc 822 on long msg headers\r
-                    if($in_headers) {\r
-                        $line = "\t" . $line;\r
-                    }\r
-                }\r
-                $lines_out[] = $line;\r
-\r
-                # now send the lines to the server\r
-                while(list(,$line_out) = @each($lines_out)) {\r
-                    if($line_out[0] == ".") {\r
-                        $line_out = "." . $line_out;\r
-                    }\r
-                    fputs($this->smtp_conn,$line_out . $this->CRLF);\r
-                }\r
-            }\r
-\r
-            # ok all the message data has been sent so lets get this\r
-            # over with aleady\r
-            fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250) {\r
-                $this->error =\r
-                    array("error" => "DATA not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * Expand($name)\r
-         *\r
-         * Expand takes the name and asks the server to list all the\r
-         * people who are members of the _list_. Expand will return\r
-         * back and array of the result or false if an error occurs.\r
-         * Each value in the array returned has the format of:\r
-         *     [ <full-name> <sp> ] <path>\r
-         * The definition of <path> is defined in rfc 821\r
-         *\r
-         * Implements rfc 821: EXPN <SP> <string> <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250\r
-         * SMTP CODE FAILURE: 550\r
-         * SMTP CODE ERROR  : 500,501,502,504,421\r
-         */\r
-        function Expand($name) {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Expand() without being connected");\r
-                return false;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250) {\r
-                $this->error =\r
-                    array("error" => "EXPN not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-\r
-            # parse the reply and place in our array to return to user\r
-            $entries = explode($this->CRLF,$rply);\r
-            while(list(,$l) = @each($entries)) {\r
-                $list[] = substr($l,4);\r
-            }\r
-\r
-            return $rval;\r
-        }\r
-\r
-        /*\r
-         * Hello($host="")\r
-         *\r
-         * Sends the HELO command to the smtp server.\r
-         * This makes sure that we and the server are in\r
-         * the same known state.\r
-         *\r
-         * Implements from rfc 821: HELO <SP> <domain> <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250\r
-         * SMTP CODE ERROR  : 500, 501, 504, 421\r
-         */\r
-        function Hello($host="") {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Hello() without being connected");\r
-                return false;\r
-            }\r
-\r
-            # if a hostname for the HELO wasn't specified determine\r
-            # a suitable one to send\r
-            if(empty($host)) {\r
-                # we need to determine some sort of appopiate default\r
-                # to send to the server\r
-                $host = "localhost";\r
-            }\r
-\r
-            fputs($this->smtp_conn,"HELO " . $host . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250) {\r
-                $this->error =\r
-                    array("error" => "HELO not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-\r
-            $this->helo_rply = $rply;\r
-\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * Help($keyword="")\r
-         *\r
-         * Gets help information on the keyword specified. If the keyword\r
-         * is not specified then returns generic help, ussually contianing\r
-         * A list of keywords that help is available on. This function\r
-         * returns the results back to the user. It is up to the user to\r
-         * handle the returned data. If an error occurs then false is\r
-         * returned with $this->error set appropiately.\r
-         *\r
-         * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 211,214\r
-         * SMTP CODE ERROR  : 500,501,502,504,421\r
-         *\r
-        function Help($keyword="") {\r
-            $this->error = null; # to avoid confusion\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Help() without being connected");\r
-                return false;\r
-            }\r
-\r
-            $extra = "";\r
-            if(!empty($keyword)) {\r
-                $extra = " " . $keyword;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 211 && $code != 214) {\r
-                $this->error =\r
-                    array("error" => "HELP not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-\r
-            return $rply;\r
-        }\r
-\r
-        /*\r
-         * Mail($from)\r
-         *\r
-         * Starts a mail transaction from the email address specified in\r
-         * $from. Returns true if successful or false otherwise. If True\r
-         * the mail transaction is started and then one or more Recipient\r
-         * commands may be called followed by a Data command.\r
-         *\r
-         * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250\r
-         * SMTP CODE SUCCESS: 552,451,452\r
-         * SMTP CODE SUCCESS: 500,501,421\r
-         */\r
-        function Mail($from) {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Mail() without being connected");\r
-                return false;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"MAIL FROM:" . $from . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250) {\r
-                $this->error =\r
-                    array("error" => "MAIL not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * Noop()\r
-         *\r
-         * Sends the command NOOP to the SMTP server.\r
-         *\r
-         * Implements from rfc 821: NOOP <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250\r
-         * SMTP CODE ERROR  : 500, 421\r
-         */\r
-        function Noop() {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Noop() without being connected");\r
-                return false;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"NOOP" . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250) {\r
-                $this->error =\r
-                    array("error" => "NOOP not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * Quit($close_on_error=true)\r
-         *\r
-         * Sends the quit command to the server and then closes the socket\r
-         * if there is no error or the $close_on_error argument is true.\r
-         *\r
-         * Implements from rfc 821: QUIT <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 221\r
-         * SMTP CODE ERROR  : 500\r
-         */\r
-        function Quit($close_on_error=true) {\r
-            $this->error = null; # so there is no confusion\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Quit() without being connected");\r
-                return false;\r
-            }\r
-\r
-            # send the quit command to the server\r
-            fputs($this->smtp_conn,"quit" . $this->CRLF);\r
-\r
-            # get any good-bye messages\r
-            $byemsg = $this->get_lines();\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;\r
-            }\r
-\r
-            $rval = true;\r
-            $e = null;\r
-\r
-            $code = substr($byemsg,0,3);\r
-            if($code != 221) {\r
-                # use e as a tmp var cause Close will overwrite $this->error\r
-                $e = array("error" => "SMTP server rejected quit command",\r
-                           "smtp_code" => $code,\r
-                           "smtp_rply" => substr($byemsg,4));\r
-                $rval = false;\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $e["error"] . ": " .\r
-                             $byemsg . $this->CRLF;\r
-                }\r
-            }\r
-\r
-            if(empty($e) || $close_on_error) {\r
-                $this->Close();\r
-            }\r
-\r
-            return $rval;\r
-        }\r
-\r
-        /*\r
-         * Recipient($to)\r
-         *\r
-         * Sends the command RCPT to the SMTP server with the TO: argument of $to.\r
-         * Returns true if the recipient was accepted false if it was rejected.\r
-         *\r
-         * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250,251\r
-         * SMTP CODE FAILURE: 550,551,552,553,450,451,452\r
-         * SMTP CODE ERROR  : 500,501,503,421\r
-         */\r
-        function Recipient($to) {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Recipient() without being connected");\r
-                return false;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"RCPT TO:" . $to . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250 && $code != 251) {\r
-                $this->error =\r
-                    array("error" => "RCPT not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * Reset()\r
-         *\r
-         * Sends the RSET command to abort and transaction that is\r
-         * currently in progress. Returns true if successful false\r
-         * otherwise.\r
-         *\r
-         * Implements rfc 821: RSET <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250\r
-         * SMTP CODE ERROR  : 500,501,504,421\r
-         */\r
-        function Reset() {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Reset() without being connected");\r
-                return false;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"RSET" . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250) {\r
-                $this->error =\r
-                    array("error" => "RSET failed",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * Send($from)\r
-         *\r
-         * Starts a mail transaction from the email address specified in\r
-         * $from. Returns true if successful or false otherwise. If True\r
-         * the mail transaction is started and then one or more Recipient\r
-         * commands may be called followed by a Data command. This command\r
-         * will send the message to the users terminal if they are logged\r
-         * in.\r
-         *\r
-         * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250\r
-         * SMTP CODE SUCCESS: 552,451,452\r
-         * SMTP CODE SUCCESS: 500,501,502,421\r
-         */\r
-        function Send($from) {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Send() without being connected");\r
-                return false;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250) {\r
-                $this->error =\r
-                    array("error" => "SEND not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * SendAndMail($from)\r
-         *\r
-         * Starts a mail transaction from the email address specified in\r
-         * $from. Returns true if successful or false otherwise. If True\r
-         * the mail transaction is started and then one or more Recipient\r
-         * commands may be called followed by a Data command. This command\r
-         * will send the message to the users terminal if they are logged\r
-         * in and send them an email.\r
-         *\r
-         * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250\r
-         * SMTP CODE SUCCESS: 552,451,452\r
-         * SMTP CODE SUCCESS: 500,501,502,421\r
-         */\r
-        function SendAndMail($from) {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                    "error" => "Called SendAndMail() without being connected");\r
-                return false;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250) {\r
-                $this->error =\r
-                    array("error" => "SAML not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * SendOrMail($from)\r
-         *\r
-         * Starts a mail transaction from the email address specified in\r
-         * $from. Returns true if successful or false otherwise. If True\r
-         * the mail transaction is started and then one or more Recipient\r
-         * commands may be called followed by a Data command. This command\r
-         * will send the message to the users terminal if they are logged\r
-         * in or mail it to them if they are not.\r
-         *\r
-         * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250\r
-         * SMTP CODE SUCCESS: 552,451,452\r
-         * SMTP CODE SUCCESS: 500,501,502,421\r
-         */\r
-        function SendOrMail($from) {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                    "error" => "Called SendOrMail() without being connected");\r
-                return false;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250) {\r
-                $this->error =\r
-                    array("error" => "SOML not accepted from server",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-        /*\r
-         * Turn()\r
-         *\r
-         * This is an optional command for SMTP that this class does not\r
-         * support. This method is here to make the RFC821 Definition\r
-         * complete for this class and __may__ be implimented in the future\r
-         *\r
-         * Implements from rfc 821: TURN <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250\r
-         * SMTP CODE FAILURE: 502\r
-         * SMTP CODE ERROR  : 500, 503\r
-         */\r
-        function Turn() {\r
-            $this->error = array("error" => "This method, TURN, of the SMTP ".\r
-                                            "is not implemented");\r
-            if($this->do_debug >= 1) {\r
-                echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;\r
-            }\r
-            return false;\r
-        }\r
-\r
-        /*\r
-         * Verify($name)\r
-         *\r
-         * Verifies that the name is recognized by the server.\r
-         * Returns false if the name could not be verified otherwise\r
-         * the response from the server is returned.\r
-         *\r
-         * Implements rfc 821: VRFY <SP> <string> <CRLF>\r
-         *\r
-         * SMTP CODE SUCCESS: 250,251\r
-         * SMTP CODE FAILURE: 550,551,553\r
-         * SMTP CODE ERROR  : 500,501,502,421\r
-         */\r
-        function Verify($name) {\r
-            $this->error = null; # so no confusion is caused\r
-\r
-            if(!$this->connected()) {\r
-                $this->error = array(\r
-                        "error" => "Called Verify() without being connected");\r
-                return false;\r
-            }\r
-\r
-            fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);\r
-\r
-            $rply = $this->get_lines();\r
-            $code = substr($rply,0,3);\r
-\r
-            if($this->do_debug >= 2) {\r
-                echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;\r
-            }\r
-\r
-            if($code != 250 && $code != 251) {\r
-                $this->error =\r
-                    array("error" => "VRFY failed on name '$name'",\r
-                          "smtp_code" => $code,\r
-                          "smtp_msg" => substr($rply,4));\r
-                if($this->do_debug >= 1) {\r
-                    echo "SMTP -> ERROR: " . $this->error["error"] .\r
-                             ": " . $rply . $this->CRLF;\r
-                }\r
-                return false;\r
-            }\r
-            return $rply;\r
-        }\r
-\r
-        /******************************************************************\r
-         *                       INTERNAL FUNCTIONS                       *\r
-         ******************************************************************/\r
-\r
-        /*\r
-         * get_lines()\r
-         *\r
-         * __internal_use_only__: read in as many lines as possible\r
-         * either before eof or socket timeout occurs on the operation.\r
-         * With SMTP we can tell if we have more lines to read if the\r
-         * 4th character is '-' symbol. If it is a space then we don't\r
-         * need to read anything else.\r
-         */\r
-        function get_lines() {\r
-            $data = "";\r
-            while($str = fgets($this->smtp_conn,515)) {\r
-                if($this->do_debug >= 4) {\r
-                    echo "SMTP -> get_lines(): \$data was \"$data\"" .\r
-                             $this->CRLF;\r
-                    echo "SMTP -> get_lines(): \$str is \"$str\"" .\r
-                             $this->CRLF;\r
-                }\r
-                $data .= $str;\r
-                if($this->do_debug >= 4) {\r
-                    echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;\r
-                }\r
-                # if the 4th character is a space then we are done reading\r
-                # so just break the loop\r
-                if(substr($str,3,1) == " ") { break; }\r
-            }\r
-            return $data;\r
-        }\r
-\r
-    }\r
-\r
-\r
- ?>\r