]> git.mxchange.org Git - mailer.git/blobdiff - 0.2.1/inc/phpmailer/class.phpmailer.php
win32 to unix line delimiters changed
[mailer.git] / 0.2.1 / inc / phpmailer / class.phpmailer.php
index d9f21aef5ed54b2c9fa15da5aa58700f0d4053de..3ca9f7cc1d9d6327a584abe6ed27a2c7c8fc7b01 100644 (file)
-<?php\r
-/*~ class.phpmailer.php\r
-.---------------------------------------------------------------------------.\r
-|  Software: PHPMailer - PHP email class                                    |\r
-|   Version: 2.0.0 rc3                                                      |\r
-|   Contact: via sourceforge.net support pages (also www.codeworxtech.com)  |\r
-|      Info: http://phpmailer.sourceforge.net                               |\r
-|   Support: http://sourceforge.net/projects/phpmailer/                     |\r
-| ------------------------------------------------------------------------- |\r
-|    Author: Andy Prevost (project admininistrator)                         |\r
-|    Author: Brent R. Matzelle (original founder)                           |\r
-| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved.               |\r
-| Copyright (c) 2001-2003, Brent R. Matzelle                                |\r
-| ------------------------------------------------------------------------- |\r
-|   License: Distributed under the Lesser General Public License (LGPL)     |\r
-|            http://www.gnu.org/copyleft/lesser.html                        |\r
-| This program is distributed in the hope that it will be useful - WITHOUT  |\r
-| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     |\r
-| FITNESS FOR A PARTICULAR PURPOSE.                                         |\r
-| ------------------------------------------------------------------------- |\r
-| We offer a number of paid services (www.codeworxtech.com):                |\r
-| - Web Hosting on highly optimized fast and secure servers                 |\r
-| - Technology Consulting                                                   |\r
-| - Oursourcing (highly qualified programmers and graphic designers)        |\r
-'---------------------------------------------------------------------------'\r
-\r
-/**\r
- * PHPMailer - PHP email transport class\r
- * @package PHPMailer\r
- * @author Andy Prevost\r
- * @copyright 2004 - 2007 Andy Prevost\r
- */\r
-\r
-class PHPMailer {\r
-\r
-  /////////////////////////////////////////////////\r
-  // PROPERTIES, PUBLIC\r
-  /////////////////////////////////////////////////\r
-\r
-  /**\r
-   * Email priority (1 = High, 3 = Normal, 5 = low).\r
-   * @var int\r
-   */\r
-  var $Priority          = 3;\r
-\r
-  /**\r
-   * Sets the CharSet of the message.\r
-   * @var string\r
-   */\r
-  var $CharSet           = 'iso-8859-1';\r
-\r
-  /**\r
-   * Sets the Content-type of the message.\r
-   * @var string\r
-   */\r
-  var $ContentType        = 'text/plain';\r
-\r
-  /**\r
-   * Sets the Encoding of the message. Options for this are "8bit",\r
-   * "7bit", "binary", "base64", and "quoted-printable".\r
-   * @var string\r
-   */\r
-  var $Encoding          = '8bit';\r
-\r
-  /**\r
-   * Holds the most recent mailer error message.\r
-   * @var string\r
-   */\r
-  var $ErrorInfo         = '';\r
-\r
-  /**\r
-   * Sets the From email address for the message.\r
-   * @var string\r
-   */\r
-  var $From              = 'root@localhost';\r
-\r
-  /**\r
-   * Sets the From name of the message.\r
-   * @var string\r
-   */\r
-  var $FromName          = 'Root User';\r
-\r
-  /**\r
-   * Sets the Sender email (Return-Path) of the message.  If not empty,\r
-   * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.\r
-   * @var string\r
-   */\r
-  var $Sender            = '';\r
-\r
-  /**\r
-   * Sets the Subject of the message.\r
-   * @var string\r
-   */\r
-  var $Subject           = '';\r
-\r
-  /**\r
-   * Sets the Body of the message.  This can be either an HTML or text body.\r
-   * If HTML then run IsHTML(true).\r
-   * @var string\r
-   */\r
-  var $Body              = '';\r
-\r
-  /**\r
-   * Sets the text-only body of the message.  This automatically sets the\r
-   * email to multipart/alternative.  This body can be read by mail\r
-   * clients that do not have HTML email capability such as mutt. Clients\r
-   * that can read HTML will view the normal Body.\r
-   * @var string\r
-   */\r
-  var $AltBody           = '';\r
-\r
-  /**\r
-   * Sets word wrapping on the body of the message to a given number of\r
-   * characters.\r
-   * @var int\r
-   */\r
-  var $WordWrap          = 0;\r
-\r
-  /**\r
-   * Method to send mail: ("mail", "sendmail", or "smtp").\r
-   * @var string\r
-   */\r
-  var $Mailer            = 'mail';\r
-\r
-  /**\r
-   * Sets the path of the sendmail program.\r
-   * @var string\r
-   */\r
-  var $Sendmail          = '/usr/sbin/sendmail';\r
-\r
-  /**\r
-   * Path to PHPMailer plugins.  This is now only useful if the SMTP class\r
-   * is in a different directory than the PHP include path.\r
-   * @var string\r
-   */\r
-  var $PluginDir         = '';\r
-\r
-  /**\r
-   * Holds PHPMailer version.\r
-   * @var string\r
-   */\r
-  var $Version           = "2.0.0 rc3";\r
-\r
-  /**\r
-   * Sets the email address that a reading confirmation will be sent.\r
-   * @var string\r
-   */\r
-  var $ConfirmReadingTo  = '';\r
-\r
-  /**\r
-   * Sets the hostname to use in Message-Id and Received headers\r
-   * and as default HELO string. If empty, the value returned\r
-   * by SERVER_NAME is used or 'localhost.localdomain'.\r
-   * @var string\r
-   */\r
-  var $Hostname          = '';\r
-\r
-  /////////////////////////////////////////////////\r
-  // PROPERTIES FOR SMTP\r
-  /////////////////////////////////////////////////\r
-\r
-  /**\r
-   * Sets the SMTP hosts.  All hosts must be separated by a\r
-   * semicolon.  You can also specify a different port\r
-   * for each host by using this format: [hostname:port]\r
-   * (e.g. "smtp1.example.com:25;smtp2.example.com").\r
-   * Hosts will be tried in order.\r
-   * @var string\r
-   */\r
-  var $Host        = 'localhost';\r
-\r
-  /**\r
-   * Sets the default SMTP server port.\r
-   * @var int\r
-   */\r
-  var $Port        = 25;\r
-\r
-  /**\r
-   * Sets the SMTP HELO of the message (Default is $Hostname).\r
-   * @var string\r
-   */\r
-  var $Helo        = '';\r
-\r
-  /**\r
-   * Sets connection prefix.\r
-   * Options are "", "ssl" or "tls"\r
-   * @var string\r
-   */\r
-  var $SMTPSecure = "";\r
-\r
-  /**\r
-   * Sets SMTP authentication. Utilizes the Username and Password variables.\r
-   * @var bool\r
-   */\r
-  var $SMTPAuth     = false;\r
-\r
-  /**\r
-   * Sets SMTP username.\r
-   * @var string\r
-   */\r
-  var $Username     = '';\r
-\r
-  /**\r
-   * Sets SMTP password.\r
-   * @var string\r
-   */\r
-  var $Password     = '';\r
-\r
-  /**\r
-   * Sets the SMTP server timeout in seconds. This function will not\r
-   * work with the win32 version.\r
-   * @var int\r
-   */\r
-  var $Timeout      = 10;\r
-\r
-  /**\r
-   * Sets SMTP class debugging on or off.\r
-   * @var bool\r
-   */\r
-  var $SMTPDebug    = false;\r
-\r
-  /**\r
-   * Prevents the SMTP connection from being closed after each mail\r
-   * sending.  If this is set to true then to close the connection\r
-   * requires an explicit call to SmtpClose().\r
-   * @var bool\r
-   */\r
-  var $SMTPKeepAlive = false;\r
-\r
-  /**\r
-   * Provides the ability to have the TO field process individual\r
-   * emails, instead of sending to entire TO addresses\r
-   * @var bool\r
-   */\r
-  var $SingleTo = false;\r
-\r
-  /////////////////////////////////////////////////\r
-  // PROPERTIES, PRIVATE\r
-  /////////////////////////////////////////////////\r
-\r
-  var $smtp            = NULL;\r
-  var $to              = array();\r
-  var $cc              = array();\r
-  var $bcc             = array();\r
-  var $ReplyTo         = array();\r
-  var $attachment      = array();\r
-  var $CustomHeader    = array();\r
-  var $message_type    = '';\r
-  var $boundary        = array();\r
-  var $language        = array();\r
-  var $error_count     = 0;\r
-  var $LE              = "\n";\r
-\r
-  /////////////////////////////////////////////////\r
-  // METHODS, VARIABLES\r
-  /////////////////////////////////////////////////\r
-\r
-  /**\r
-   * Sets message type to HTML.\r
-   * @param bool $bool\r
-   * @return void\r
-   */\r
-  function IsHTML($bool) {\r
-    if($bool == true) {\r
-      $this->ContentType = 'text/html';\r
-    } else {\r
-      $this->ContentType = 'text/plain';\r
-    }\r
-  }\r
-\r
-  /**\r
-   * Sets Mailer to send message using SMTP.\r
-   * @return void\r
-   */\r
-  function IsSMTP() {\r
-    $this->Mailer = 'smtp';\r
-  }\r
-\r
-  /**\r
-   * Sets Mailer to send message using PHP mail() function.\r
-   * @return void\r
-   */\r
-  function IsMail() {\r
-    $this->Mailer = 'mail';\r
-  }\r
-\r
-  /**\r
-   * Sets Mailer to send message using the $Sendmail program.\r
-   * @return void\r
-   */\r
-  function IsSendmail() {\r
-    $this->Mailer = 'sendmail';\r
-  }\r
-\r
-  /**\r
-   * Sets Mailer to send message using the qmail MTA.\r
-   * @return void\r
-   */\r
-  function IsQmail() {\r
-    $this->Sendmail = '/var/qmail/bin/sendmail';\r
-    $this->Mailer = 'sendmail';\r
-  }\r
-\r
-  /////////////////////////////////////////////////\r
-  // METHODS, RECIPIENTS\r
-  /////////////////////////////////////////////////\r
-\r
-  /**\r
-   * Adds a "To" address.\r
-   * @param string $address\r
-   * @param string $name\r
-   * @return void\r
-   */\r
-  function AddAddress($address, $name = '') {\r
-    $cur = count($this->to);\r
-    $this->to[$cur][0] = trim($address);\r
-    $this->to[$cur][1] = $name;\r
-  }\r
-\r
-  /**\r
-   * Adds a "Cc" address. Note: this function works\r
-   * with the SMTP mailer on win32, not with the "mail"\r
-   * mailer.\r
-   * @param string $address\r
-   * @param string $name\r
-   * @return void\r
-   */\r
-  function AddCC($address, $name = '') {\r
-    $cur = count($this->cc);\r
-    $this->cc[$cur][0] = trim($address);\r
-    $this->cc[$cur][1] = $name;\r
-  }\r
-\r
-  /**\r
-   * Adds a "Bcc" address. Note: this function works\r
-   * with the SMTP mailer on win32, not with the "mail"\r
-   * mailer.\r
-   * @param string $address\r
-   * @param string $name\r
-   * @return void\r
-   */\r
-  function AddBCC($address, $name = '') {\r
-    $cur = count($this->bcc);\r
-    $this->bcc[$cur][0] = trim($address);\r
-    $this->bcc[$cur][1] = $name;\r
-  }\r
-\r
-  /**\r
-   * Adds a "Reply-To" address.\r
-   * @param string $address\r
-   * @param string $name\r
-   * @return void\r
-   */\r
-  function AddReplyTo($address, $name = '') {\r
-    $cur = count($this->ReplyTo);\r
-    $this->ReplyTo[$cur][0] = trim($address);\r
-    $this->ReplyTo[$cur][1] = $name;\r
-  }\r
-\r
-  /////////////////////////////////////////////////\r
-  // METHODS, MAIL SENDING\r
-  /////////////////////////////////////////////////\r
-\r
-  /**\r
-   * Creates message and assigns Mailer. If the message is\r
-   * not sent successfully then it returns false.  Use the ErrorInfo\r
-   * variable to view description of the error.\r
-   * @return bool\r
-   */\r
-  function Send() {\r
-    $header = '';\r
-    $body = '';\r
-    $result = true;\r
-\r
-    if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {\r
-      $this->SetError($this->Lang('provide_address'));\r
-      return false;\r
-    }\r
-\r
-    /* Set whether the message is multipart/alternative */\r
-    if(!empty($this->AltBody)) {\r
-      $this->ContentType = 'multipart/alternative';\r
-    }\r
-\r
-    $this->error_count = 0; // reset errors\r
-    $this->SetMessageType();\r
-    $header .= $this->CreateHeader();\r
-    $body = $this->CreateBody();\r
-\r
-    if($body == '') {\r
-      return false;\r
-    }\r
-\r
-    /* Choose the mailer */\r
-    switch($this->Mailer) {\r
-      case 'sendmail':\r
-        $result = $this->SendmailSend($header, $body);\r
-        break;\r
-      case 'smtp':\r
-        $result = $this->SmtpSend($header, $body);\r
-        break;\r
-      case 'mail':\r
-        $result = $this->MailSend($header, $body);\r
-        break;\r
-      default:\r
-        $result = $this->MailSend($header, $body);\r
-        break;\r
-        //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));\r
-        //$result = false;\r
-        //break;\r
-    }\r
-\r
-    return $result;\r
-  }\r
-\r
-  /**\r
-   * Sends mail using the $Sendmail program.\r
-   * @access private\r
-   * @return bool\r
-   */\r
-  function SendmailSend($header, $body) {\r
-    if ($this->Sender != '') {\r
-      $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));\r
-    } else {\r
-      $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));\r
-    }\r
-\r
-    if(!@$mail = popen($sendmail, 'w')) {\r
-      $this->SetError($this->Lang('execute') . $this->Sendmail);\r
-      return false;\r
-    }\r
-\r
-    fputs($mail, $header);\r
-    fputs($mail, $body);\r
-\r
-    $result = pclose($mail) >> 8 & 0xFF;\r
-    if($result != 0) {\r
-      $this->SetError($this->Lang('execute') . $this->Sendmail);\r
-      return false;\r
-    }\r
-\r
-    return true;\r
-  }\r
-\r
-  /**\r
-   * Sends mail using the PHP mail() function.\r
-   * @access private\r
-   * @return bool\r
-   */\r
-  function MailSend($header, $body) {\r
-\r
-    $to = '';\r
-    for($i = 0; $i < count($this->to); $i++) {\r
-      if($i != 0) { $to .= ', '; }\r
-      $to .= $this->AddrFormat($this->to[$i]);\r
-    }\r
-\r
-    $toArr = split(',', $to);\r
-\r
-    if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {\r
-      $old_from = ini_get('sendmail_from');\r
-      ini_set('sendmail_from', $this->Sender);\r
-      $params = sprintf("-oi -f %s", $this->Sender);\r
-      if ($this->SingleTo === true && count($toArr) > 1) {\r
-        foreach ($toArr as $key => $val) {\r
-          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);\r
-        }\r
-      } else {\r
-        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);\r
-      }\r
-    } else {\r
-      if ($this->SingleTo === true && count($toArr) > 1) {\r
-        foreach ($toArr as $key => $val) {\r
-          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);\r
-        }\r
-      } else {\r
-        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);\r
-      }\r
-    }\r
-\r
-    if (isset($old_from)) {\r
-      ini_set('sendmail_from', $old_from);\r
-    }\r
-\r
-    if(!$rt) {\r
-      $this->SetError($this->Lang('instantiate'));\r
-      return false;\r
-    }\r
-\r
-    return true;\r
-  }\r
-\r
-  /**\r
-   * Sends mail via SMTP using PhpSMTP (Author:\r
-   * Chris Ryan).  Returns bool.  Returns false if there is a\r
-   * bad MAIL FROM, RCPT, or DATA input.\r
-   * @access private\r
-   * @return bool\r
-   */\r
-  function SmtpSend($header, $body) {\r
-    include_once($this->PluginDir . 'class.smtp.php');\r
-    $error = '';\r
-    $bad_rcpt = array();\r
-\r
-    if(!$this->SmtpConnect()) {\r
-      return false;\r
-    }\r
-\r
-    $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;\r
-    if(!$this->smtp->Mail($smtp_from)) {\r
-      $error = $this->Lang('from_failed') . $smtp_from;\r
-      $this->SetError($error);\r
-      $this->smtp->Reset();\r
-      return false;\r
-    }\r
-\r
-    /* Attempt to send attach all recipients */\r
-    for($i = 0; $i < count($this->to); $i++) {\r
-      if(!$this->smtp->Recipient($this->to[$i][0])) {\r
-        $bad_rcpt[] = $this->to[$i][0];\r
-      }\r
-    }\r
-    for($i = 0; $i < count($this->cc); $i++) {\r
-      if(!$this->smtp->Recipient($this->cc[$i][0])) {\r
-        $bad_rcpt[] = $this->cc[$i][0];\r
-      }\r
-    }\r
-    for($i = 0; $i < count($this->bcc); $i++) {\r
-      if(!$this->smtp->Recipient($this->bcc[$i][0])) {\r
-        $bad_rcpt[] = $this->bcc[$i][0];\r
-      }\r
-    }\r
-\r
-    if(count($bad_rcpt) > 0) { // Create error message\r
-      for($i = 0; $i < count($bad_rcpt); $i++) {\r
-        if($i != 0) {\r
-          $error .= ', ';\r
-        }\r
-        $error .= $bad_rcpt[$i];\r
-      }\r
-      $error = $this->Lang('recipients_failed') . $error;\r
-      $this->SetError($error);\r
-      $this->smtp->Reset();\r
-      return false;\r
-    }\r
-\r
-    if(!$this->smtp->Data($header . $body)) {\r
-      $this->SetError($this->Lang('data_not_accepted'));\r
-      $this->smtp->Reset();\r
-      return false;\r
-    }\r
-    if($this->SMTPKeepAlive == true) {\r
-      $this->smtp->Reset();\r
-    } else {\r
-      $this->SmtpClose();\r
-    }\r
-\r
-    return true;\r
-  }\r
-\r
-  /**\r
-   * Initiates a connection to an SMTP server.  Returns false if the\r
-   * operation failed.\r
-   * @access private\r
-   * @return bool\r
-   */\r
-  function SmtpConnect() {\r
-    if($this->smtp == NULL) {\r
-      $this->smtp = new SMTP();\r
-    }\r
-\r
-    $this->smtp->do_debug = $this->SMTPDebug;\r
-    $hosts = explode(';', $this->Host);\r
-    $index = 0;\r
-    $connection = ($this->smtp->Connected());\r
-\r
-    /* Retry while there is no connection */\r
-    while($index < count($hosts) && $connection == false) {\r
-      $hostinfo = array();\r
-      if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {\r
-        $host = $hostinfo[1];\r
-        $port = $hostinfo[2];\r
-      } else {\r
-        $host = $hosts[$index];\r
-        $port = $this->Port;\r
-      }\r
-\r
-      if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) {\r
-        if ($this->Helo != '') {\r
-          $this->smtp->Hello($this->Helo);\r
-        } else {\r
-          $this->smtp->Hello($this->ServerHostname());\r
-        }\r
-\r
-        $connection = true;\r
-        if($this->SMTPAuth) {\r
-          if(!$this->smtp->Authenticate($this->Username, $this->Password)) {\r
-            $this->SetError($this->Lang('authenticate'));\r
-            $this->smtp->Reset();\r
-            $connection = false;\r
-          }\r
-        }\r
-      }\r
-      $index++;\r
-    }\r
-    if(!$connection) {\r
-      $this->SetError($this->Lang('connect_host'));\r
-    }\r
-\r
-    return $connection;\r
-  }\r
-\r
-  /**\r
-   * Closes the active SMTP session if one exists.\r
-   * @return void\r
-   */\r
-  function SmtpClose() {\r
-    if($this->smtp != NULL) {\r
-      if($this->smtp->Connected()) {\r
-        $this->smtp->Quit();\r
-        $this->smtp->Close();\r
-      }\r
-    }\r
-  }\r
-\r
-  /**\r
-   * Sets the language for all class error messages.  Returns false\r
-   * if it cannot load the language file.  The default language type\r
-   * is English.\r
-   * @param string $lang_type Type of language (e.g. Portuguese: "br")\r
-   * @param string $lang_path Path to the language file directory\r
-   * @access public\r
-   * @return bool\r
-   */\r
-  function SetLanguage($lang_type, $lang_path = 'language/') {\r
-    if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) {\r
-      include($lang_path.'phpmailer.lang-'.$lang_type.'.php');\r
-    } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) {\r
-      include($lang_path.'phpmailer.lang-en.php');\r
-    } else {\r
-      $this->SetError('Could not load language file');\r
-      return false;\r
-    }\r
-    $this->language = $PHPMAILER_LANG;\r
-\r
-    return true;\r
-  }\r
-\r
-  /////////////////////////////////////////////////\r
-  // METHODS, MESSAGE CREATION\r
-  /////////////////////////////////////////////////\r
-\r
-  /**\r
-   * Creates recipient headers.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function AddrAppend($type, $addr) {\r
-    $addr_str = $type . ': ';\r
-    $addr_str .= $this->AddrFormat($addr[0]);\r
-    if(count($addr) > 1) {\r
-      for($i = 1; $i < count($addr); $i++) {\r
-        $addr_str .= ', ' . $this->AddrFormat($addr[$i]);\r
-      }\r
-    }\r
-    $addr_str .= $this->LE;\r
-\r
-    return $addr_str;\r
-  }\r
-\r
-  /**\r
-   * Formats an address correctly.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function AddrFormat($addr) {\r
-    if(empty($addr[1])) {\r
-      $formatted = $this->SecureHeader($addr[0]);\r
-    } else {\r
-      $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";\r
-    }\r
-\r
-    return $formatted;\r
-  }\r
-\r
-  /**\r
-   * Wraps message for use with mailers that do not\r
-   * automatically perform wrapping and for quoted-printable.\r
-   * Original written by philippe.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function WrapText($message, $length, $qp_mode = false) {\r
-    $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;\r
-\r
-    $message = $this->FixEOL($message);\r
-    if (substr($message, -1) == $this->LE) {\r
-      $message = substr($message, 0, -1);\r
-    }\r
-\r
-    $line = explode($this->LE, $message);\r
-    $message = '';\r
-    for ($i=0 ;$i < count($line); $i++) {\r
-      $line_part = explode(' ', $line[$i]);\r
-      $buf = '';\r
-      for ($e = 0; $e<count($line_part); $e++) {\r
-        $word = $line_part[$e];\r
-        if ($qp_mode and (strlen($word) > $length)) {\r
-          $space_left = $length - strlen($buf) - 1;\r
-          if ($e != 0) {\r
-            if ($space_left > 20) {\r
-              $len = $space_left;\r
-              if (substr($word, $len - 1, 1) == '=') {\r
-                $len--;\r
-              } elseif (substr($word, $len - 2, 1) == '=') {\r
-                $len -= 2;\r
-              }\r
-              $part = substr($word, 0, $len);\r
-              $word = substr($word, $len);\r
-              $buf .= ' ' . $part;\r
-              $message .= $buf . sprintf("=%s", $this->LE);\r
-            } else {\r
-              $message .= $buf . $soft_break;\r
-            }\r
-            $buf = '';\r
-          }\r
-          while (strlen($word) > 0) {\r
-            $len = $length;\r
-            if (substr($word, $len - 1, 1) == '=') {\r
-              $len--;\r
-            } elseif (substr($word, $len - 2, 1) == '=') {\r
-              $len -= 2;\r
-            }\r
-            $part = substr($word, 0, $len);\r
-            $word = substr($word, $len);\r
-\r
-            if (strlen($word) > 0) {\r
-              $message .= $part . sprintf("=%s", $this->LE);\r
-            } else {\r
-              $buf = $part;\r
-            }\r
-          }\r
-        } else {\r
-          $buf_o = $buf;\r
-          $buf .= ($e == 0) ? $word : (' ' . $word);\r
-\r
-          if (strlen($buf) > $length and $buf_o != '') {\r
-            $message .= $buf_o . $soft_break;\r
-            $buf = $word;\r
-          }\r
-        }\r
-      }\r
-      $message .= $buf . $this->LE;\r
-    }\r
-\r
-    return $message;\r
-  }\r
-\r
-  /**\r
-   * Set the body wrapping.\r
-   * @access private\r
-   * @return void\r
-   */\r
-  function SetWordWrap() {\r
-    if($this->WordWrap < 1) {\r
-      return;\r
-    }\r
-\r
-    switch($this->message_type) {\r
-      case 'alt':\r
-        /* fall through */\r
-      case 'alt_attachments':\r
-        $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);\r
-        break;\r
-      default:\r
-        $this->Body = $this->WrapText($this->Body, $this->WordWrap);\r
-        break;\r
-    }\r
-  }\r
-\r
-  /**\r
-   * Assembles message header.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function CreateHeader() {\r
-    $result = '';\r
-\r
-    /* Set the boundaries */\r
-    $uniq_id = md5(uniqid(time()));\r
-    $this->boundary[1] = 'b1_' . $uniq_id;\r
-    $this->boundary[2] = 'b2_' . $uniq_id;\r
-\r
-    $result .= $this->HeaderLine('Date', $this->RFCDate());\r
-    if($this->Sender == '') {\r
-      $result .= $this->HeaderLine('Return-Path', trim($this->From));\r
-    } else {\r
-      $result .= $this->HeaderLine('Return-Path', trim($this->Sender));\r
-    }\r
-\r
-    /* To be created automatically by mail() */\r
-    if($this->Mailer != 'mail') {\r
-      if(count($this->to) > 0) {\r
-        $result .= $this->AddrAppend('To', $this->to);\r
-      } elseif (count($this->cc) == 0) {\r
-        $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');\r
-      }\r
-      if(count($this->cc) > 0) {\r
-        $result .= $this->AddrAppend('Cc', $this->cc);\r
-      }\r
-    }\r
-\r
-    $from = array();\r
-    $from[0][0] = trim($this->From);\r
-    $from[0][1] = $this->FromName;\r
-    $result .= $this->AddrAppend('From', $from);\r
-\r
-    /* sendmail and mail() extract Cc from the header before sending */\r
-    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {\r
-      $result .= $this->AddrAppend('Cc', $this->cc);\r
-    }\r
-\r
-    /* sendmail and mail() extract Bcc from the header before sending */\r
-    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {\r
-      $result .= $this->AddrAppend('Bcc', $this->bcc);\r
-    }\r
-\r
-    if(count($this->ReplyTo) > 0) {\r
-      $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);\r
-    }\r
-\r
-    /* mail() sets the subject itself */\r
-    if($this->Mailer != 'mail') {\r
-      $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));\r
-    }\r
-\r
-    $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);\r
-    $result .= $this->HeaderLine('X-Priority', $this->Priority);\r
-    $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']');\r
-\r
-    if($this->ConfirmReadingTo != '') {\r
-      $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');\r
-    }\r
-\r
-    // Add custom headers\r
-    for($index = 0; $index < count($this->CustomHeader); $index++) {\r
-      $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));\r
-    }\r
-    $result .= $this->HeaderLine('MIME-Version', '1.0');\r
-\r
-    switch($this->message_type) {\r
-      case 'plain':\r
-        $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);\r
-        $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);\r
-        break;\r
-      case 'attachments':\r
-        /* fall through */\r
-      case 'alt_attachments':\r
-        if($this->InlineImageExists()){\r
-          $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);\r
-        } else {\r
-          $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');\r
-          $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');\r
-        }\r
-        break;\r
-      case 'alt':\r
-        $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');\r
-        $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');\r
-        break;\r
-    }\r
-\r
-    if($this->Mailer != 'mail') {\r
-      $result .= $this->LE.$this->LE;\r
-    }\r
-\r
-    return $result;\r
-  }\r
-\r
-  /**\r
-   * Assembles the message body.  Returns an empty string on failure.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function CreateBody() {\r
-    $result = '';\r
-\r
-    $this->SetWordWrap();\r
-\r
-    switch($this->message_type) {\r
-      case 'alt':\r
-        $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');\r
-        $result .= $this->EncodeString($this->AltBody, $this->Encoding);\r
-        $result .= $this->LE.$this->LE;\r
-        $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');\r
-        $result .= $this->EncodeString($this->Body, $this->Encoding);\r
-        $result .= $this->LE.$this->LE;\r
-        $result .= $this->EndBoundary($this->boundary[1]);\r
-        break;\r
-      case 'plain':\r
-        $result .= $this->EncodeString($this->Body, $this->Encoding);\r
-        break;\r
-      case 'attachments':\r
-        $result .= $this->GetBoundary($this->boundary[1], '', '', '');\r
-        $result .= $this->EncodeString($this->Body, $this->Encoding);\r
-        $result .= $this->LE;\r
-        $result .= $this->AttachAll();\r
-        break;\r
-      case 'alt_attachments':\r
-        $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);\r
-        $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);\r
-        $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body\r
-        $result .= $this->EncodeString($this->AltBody, $this->Encoding);\r
-        $result .= $this->LE.$this->LE;\r
-        $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body\r
-        $result .= $this->EncodeString($this->Body, $this->Encoding);\r
-        $result .= $this->LE.$this->LE;\r
-        $result .= $this->EndBoundary($this->boundary[2]);\r
-        $result .= $this->AttachAll();\r
-        break;\r
-    }\r
-    if($this->IsError()) {\r
-      $result = '';\r
-    }\r
-\r
-    return $result;\r
-  }\r
-\r
-  /**\r
-   * Returns the start of a message boundary.\r
-   * @access private\r
-   */\r
-  function GetBoundary($boundary, $charSet, $contentType, $encoding) {\r
-    $result = '';\r
-    if($charSet == '') {\r
-      $charSet = $this->CharSet;\r
-    }\r
-    if($contentType == '') {\r
-      $contentType = $this->ContentType;\r
-    }\r
-    if($encoding == '') {\r
-      $encoding = $this->Encoding;\r
-    }\r
-    $result .= $this->TextLine('--' . $boundary);\r
-    $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);\r
-    $result .= $this->LE;\r
-    $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);\r
-    $result .= $this->LE;\r
-\r
-    return $result;\r
-  }\r
-\r
-  /**\r
-   * Returns the end of a message boundary.\r
-   * @access private\r
-   */\r
-  function EndBoundary($boundary) {\r
-    return $this->LE . '--' . $boundary . '--' . $this->LE;\r
-  }\r
-\r
-  /**\r
-   * Sets the message type.\r
-   * @access private\r
-   * @return void\r
-   */\r
-  function SetMessageType() {\r
-    if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {\r
-      $this->message_type = 'plain';\r
-    } else {\r
-      if(count($this->attachment) > 0) {\r
-        $this->message_type = 'attachments';\r
-      }\r
-      if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {\r
-        $this->message_type = 'alt';\r
-      }\r
-      if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {\r
-        $this->message_type = 'alt_attachments';\r
-      }\r
-    }\r
-  }\r
-\r
-  /* Returns a formatted header line.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function HeaderLine($name, $value) {\r
-    return $name . ': ' . $value . $this->LE;\r
-  }\r
-\r
-  /**\r
-   * Returns a formatted mail line.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function TextLine($value) {\r
-    return $value . $this->LE;\r
-  }\r
-\r
-  /////////////////////////////////////////////////\r
-  // CLASS METHODS, ATTACHMENTS\r
-  /////////////////////////////////////////////////\r
-\r
-  /**\r
-   * Adds an attachment from a path on the filesystem.\r
-   * Returns false if the file could not be found\r
-   * or accessed.\r
-   * @param string $path Path to the attachment.\r
-   * @param string $name Overrides the attachment name.\r
-   * @param string $encoding File encoding (see $Encoding).\r
-   * @param string $type File extension (MIME) type.\r
-   * @return bool\r
-   */\r
-  function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {\r
-    if(!@is_file($path)) {\r
-      $this->SetError($this->Lang('file_access') . $path);\r
-      return false;\r
-    }\r
-\r
-    $filename = basename($path);\r
-    if($name == '') {\r
-      $name = $filename;\r
-    }\r
-\r
-    $cur = count($this->attachment);\r
-    $this->attachment[$cur][0] = $path;\r
-    $this->attachment[$cur][1] = $filename;\r
-    $this->attachment[$cur][2] = $name;\r
-    $this->attachment[$cur][3] = $encoding;\r
-    $this->attachment[$cur][4] = $type;\r
-    $this->attachment[$cur][5] = false; // isStringAttachment\r
-    $this->attachment[$cur][6] = 'attachment';\r
-    $this->attachment[$cur][7] = 0;\r
-\r
-    return true;\r
-  }\r
-\r
-  /**\r
-   * Attaches all fs, string, and binary attachments to the message.\r
-   * Returns an empty string on failure.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function AttachAll() {\r
-    /* Return text of body */\r
-    $mime = array();\r
-\r
-    /* Add all attachments */\r
-    for($i = 0; $i < count($this->attachment); $i++) {\r
-      /* Check for string attachment */\r
-      $bString = $this->attachment[$i][5];\r
-      if ($bString) {\r
-        $string = $this->attachment[$i][0];\r
-      } else {\r
-        $path = $this->attachment[$i][0];\r
-      }\r
-\r
-      $filename    = $this->attachment[$i][1];\r
-      $name        = $this->attachment[$i][2];\r
-      $encoding    = $this->attachment[$i][3];\r
-      $type        = $this->attachment[$i][4];\r
-      $disposition = $this->attachment[$i][6];\r
-      $cid         = $this->attachment[$i][7];\r
-\r
-      $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);\r
-      $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);\r
-      $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);\r
-\r
-      if($disposition == 'inline') {\r
-        $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);\r
-      }\r
-\r
-      $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE);\r
-\r
-      /* Encode as string attachment */\r
-      if($bString) {\r
-        $mime[] = $this->EncodeString($string, $encoding);\r
-        if($this->IsError()) {\r
-          return '';\r
-        }\r
-        $mime[] = $this->LE.$this->LE;\r
-      } else {\r
-        $mime[] = $this->EncodeFile($path, $encoding);\r
-        if($this->IsError()) {\r
-          return '';\r
-        }\r
-        $mime[] = $this->LE.$this->LE;\r
-      }\r
-    }\r
-\r
-    $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);\r
-\r
-    return join('', $mime);\r
-  }\r
-\r
-  /**\r
-   * Encodes attachment in requested format.  Returns an\r
-   * empty string on failure.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function EncodeFile ($path, $encoding = 'base64') {\r
-    if(!@$fd = fopen($path, 'rb')) {\r
-      $this->SetError($this->Lang('file_open') . $path);\r
-      return '';\r
-    }\r
-    $magic_quotes = get_magic_quotes_runtime();\r
-    set_magic_quotes_runtime(0);\r
-    $file_buffer = fread($fd, filesize($path));\r
-    $file_buffer = $this->EncodeString($file_buffer, $encoding);\r
-    fclose($fd);\r
-    set_magic_quotes_runtime($magic_quotes);\r
-\r
-    return $file_buffer;\r
-  }\r
-\r
-  /**\r
-   * Encodes string to requested format. Returns an\r
-   * empty string on failure.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function EncodeString ($str, $encoding = 'base64') {\r
-    $encoded = '';\r
-    switch(strtolower($encoding)) {\r
-      case 'base64':\r
-        /* chunk_split is found in PHP >= 3.0.6 */\r
-        $encoded = chunk_split(base64_encode($str), 76, $this->LE);\r
-        break;\r
-      case '7bit':\r
-      case '8bit':\r
-        $encoded = $this->FixEOL($str);\r
-        if (substr($encoded, -(strlen($this->LE))) != $this->LE)\r
-          $encoded .= $this->LE;\r
-        break;\r
-      case 'binary':\r
-        $encoded = $str;\r
-        break;\r
-      case 'quoted-printable':\r
-        $encoded = $this->EncodeQP($str);\r
-        break;\r
-      default:\r
-        $this->SetError($this->Lang('encoding') . $encoding);\r
-        break;\r
-    }\r
-    return $encoded;\r
-  }\r
-\r
-  /**\r
-   * Encode a header string to best of Q, B, quoted or none.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function EncodeHeader ($str, $position = 'text') {\r
-    $x = 0;\r
-\r
-    switch (strtolower($position)) {\r
-      case 'phrase':\r
-        if (!preg_match('/[\200-\377]/', $str)) {\r
-          /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */\r
-          $encoded = addcslashes($str, "\0..\37\177\\\"");\r
-          if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {\r
-            return ($encoded);\r
-          } else {\r
-            return ("\"$encoded\"");\r
-          }\r
-        }\r
-        $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);\r
-        break;\r
-      case 'comment':\r
-        $x = preg_match_all('/[()"]/', $str, $matches);\r
-        /* Fall-through */\r
-      case 'text':\r
-      default:\r
-        $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);\r
-        break;\r
-    }\r
-\r
-    if ($x == 0) {\r
-      return ($str);\r
-    }\r
-\r
-    $maxlen = 75 - 7 - strlen($this->CharSet);\r
-    /* Try to select the encoding which should produce the shortest output */\r
-    if (strlen($str)/3 < $x) {\r
-      $encoding = 'B';\r
-      $encoded = base64_encode($str);\r
-      $maxlen -= $maxlen % 4;\r
-      $encoded = trim(chunk_split($encoded, $maxlen, "\n"));\r
-    } else {\r
-      $encoding = 'Q';\r
-      $encoded = $this->EncodeQ($str, $position);\r
-      $encoded = $this->WrapText($encoded, $maxlen, true);\r
-      $encoded = str_replace('='.$this->LE, "\n", trim($encoded));\r
-    }\r
-\r
-    $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);\r
-    $encoded = trim(str_replace("\n", $this->LE, $encoded));\r
-\r
-    return $encoded;\r
-  }\r
-\r
-  /**\r
-   * Encode string to quoted-printable.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {\r
-    $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');\r
-    $lines = preg_split('/(?:\r\n|\r|\n)/', $input);\r
-    $eol = "\r\n";\r
-    $escape = '=';\r
-    $output = '';\r
-    while( list(, $line) = each($lines) ) {\r
-      $linlen = strlen($line);\r
-      $newline = '';\r
-      for($i = 0; $i < $linlen; $i++) {\r
-        $c = substr( $line, $i, 1 );\r
-        $dec = ord( $c );\r
-        if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E\r
-          $c = '=2E';\r
-        }\r
-        if ( $dec == 32 ) {\r
-          if ( $i == ( $linlen - 1 ) ) { // convert space at eol only\r
-            $c = '=20';\r
-          } else if ( $space_conv ) {\r
-            $c = '=20';\r
-          }\r
-        } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required\r
-          $h2 = floor($dec/16);\r
-          $h1 = floor($dec%16);\r
-          $c = $escape.$hex[$h2].$hex[$h1];\r
-        }\r
-        if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted\r
-          $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay\r
-          $newline = '';\r
-          // check if newline first character will be point or not\r
-          if ( $dec == 46 ) {\r
-            $c = '=2E';\r
-          }\r
-        }\r
-        $newline .= $c;\r
-      } // end of for\r
-      $output .= $newline.$eol;\r
-    } // end of while\r
-    return trim($output);\r
-  }\r
-\r
-  /**\r
-   * Encode string to q encoding.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function EncodeQ ($str, $position = 'text') {\r
-    /* There should not be any EOL in the string */\r
-    $encoded = preg_replace("[\r\n]", '', $str);\r
-\r
-    switch (strtolower($position)) {\r
-      case 'phrase':\r
-        $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);\r
-        break;\r
-      case 'comment':\r
-        $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);\r
-      case 'text':\r
-      default:\r
-        /* Replace every high ascii, control =, ? and _ characters */\r
-        $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',\r
-              "'='.sprintf('%02X', ord('\\1'))", $encoded);\r
-        break;\r
-    }\r
-\r
-    /* Replace every spaces to _ (more readable than =20) */\r
-    $encoded = str_replace(' ', '_', $encoded);\r
-\r
-    return $encoded;\r
-  }\r
-\r
-  /**\r
-   * Adds a string or binary attachment (non-filesystem) to the list.\r
-   * This method can be used to attach ascii or binary data,\r
-   * such as a BLOB record from a database.\r
-   * @param string $string String attachment data.\r
-   * @param string $filename Name of the attachment.\r
-   * @param string $encoding File encoding (see $Encoding).\r
-   * @param string $type File extension (MIME) type.\r
-   * @return void\r
-   */\r
-  function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {\r
-    /* Append to $attachment array */\r
-    $cur = count($this->attachment);\r
-    $this->attachment[$cur][0] = $string;\r
-    $this->attachment[$cur][1] = $filename;\r
-    $this->attachment[$cur][2] = $filename;\r
-    $this->attachment[$cur][3] = $encoding;\r
-    $this->attachment[$cur][4] = $type;\r
-    $this->attachment[$cur][5] = true; // isString\r
-    $this->attachment[$cur][6] = 'attachment';\r
-    $this->attachment[$cur][7] = 0;\r
-  }\r
-\r
-  /**\r
-   * Adds an embedded attachment.  This can include images, sounds, and\r
-   * just about any other document.  Make sure to set the $type to an\r
-   * image type.  For JPEG images use "image/jpeg" and for GIF images\r
-   * use "image/gif".\r
-   * @param string $path Path to the attachment.\r
-   * @param string $cid Content ID of the attachment.  Use this to identify\r
-   *        the Id for accessing the image in an HTML form.\r
-   * @param string $name Overrides the attachment name.\r
-   * @param string $encoding File encoding (see $Encoding).\r
-   * @param string $type File extension (MIME) type.\r
-   * @return bool\r
-   */\r
-  function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {\r
-\r
-    if(!@is_file($path)) {\r
-      $this->SetError($this->Lang('file_access') . $path);\r
-      return false;\r
-    }\r
-\r
-    $filename = basename($path);\r
-    if($name == '') {\r
-      $name = $filename;\r
-    }\r
-\r
-    /* Append to $attachment array */\r
-    $cur = count($this->attachment);\r
-    $this->attachment[$cur][0] = $path;\r
-    $this->attachment[$cur][1] = $filename;\r
-    $this->attachment[$cur][2] = $name;\r
-    $this->attachment[$cur][3] = $encoding;\r
-    $this->attachment[$cur][4] = $type;\r
-    $this->attachment[$cur][5] = false;\r
-    $this->attachment[$cur][6] = 'inline';\r
-    $this->attachment[$cur][7] = $cid;\r
-\r
-    return true;\r
-  }\r
-\r
-  /**\r
-   * Returns true if an inline attachment is present.\r
-   * @access private\r
-   * @return bool\r
-   */\r
-  function InlineImageExists() {\r
-    $result = false;\r
-    for($i = 0; $i < count($this->attachment); $i++) {\r
-      if($this->attachment[$i][6] == 'inline') {\r
-        $result = true;\r
-        break;\r
-      }\r
-    }\r
-\r
-    return $result;\r
-  }\r
-\r
-  /////////////////////////////////////////////////\r
-  // CLASS METHODS, MESSAGE RESET\r
-  /////////////////////////////////////////////////\r
-\r
-  /**\r
-   * Clears all recipients assigned in the TO array.  Returns void.\r
-   * @return void\r
-   */\r
-  function ClearAddresses() {\r
-    $this->to = array();\r
-  }\r
-\r
-  /**\r
-   * Clears all recipients assigned in the CC array.  Returns void.\r
-   * @return void\r
-   */\r
-  function ClearCCs() {\r
-    $this->cc = array();\r
-  }\r
-\r
-  /**\r
-   * Clears all recipients assigned in the BCC array.  Returns void.\r
-   * @return void\r
-   */\r
-  function ClearBCCs() {\r
-    $this->bcc = array();\r
-  }\r
-\r
-  /**\r
-   * Clears all recipients assigned in the ReplyTo array.  Returns void.\r
-   * @return void\r
-   */\r
-  function ClearReplyTos() {\r
-    $this->ReplyTo = array();\r
-  }\r
-\r
-  /**\r
-   * Clears all recipients assigned in the TO, CC and BCC\r
-   * array.  Returns void.\r
-   * @return void\r
-   */\r
-  function ClearAllRecipients() {\r
-    $this->to = array();\r
-    $this->cc = array();\r
-    $this->bcc = array();\r
-  }\r
-\r
-  /**\r
-   * Clears all previously set filesystem, string, and binary\r
-   * attachments.  Returns void.\r
-   * @return void\r
-   */\r
-  function ClearAttachments() {\r
-    $this->attachment = array();\r
-  }\r
-\r
-  /**\r
-   * Clears all custom headers.  Returns void.\r
-   * @return void\r
-   */\r
-  function ClearCustomHeaders() {\r
-    $this->CustomHeader = array();\r
-  }\r
-\r
-  /////////////////////////////////////////////////\r
-  // CLASS METHODS, MISCELLANEOUS\r
-  /////////////////////////////////////////////////\r
-\r
-  /**\r
-   * Adds the error message to the error container.\r
-   * Returns void.\r
-   * @access private\r
-   * @return void\r
-   */\r
-  function SetError($msg) {\r
-    $this->error_count++;\r
-    $this->ErrorInfo = $msg;\r
-  }\r
-\r
-  /**\r
-   * Returns the proper RFC 822 formatted date.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function RFCDate() {\r
-    $tz = date('Z');\r
-    $tzs = ($tz < 0) ? '-' : '+';\r
-    $tz = abs($tz);\r
-    $tz = (int)($tz/3600)*100 + ($tz%3600)/60;\r
-    $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);\r
-\r
-    return $result;\r
-  }\r
-\r
-  /**\r
-   * Returns the appropriate server variable.  Should work with both\r
-   * PHP 4.1.0+ as well as older versions.  Returns an empty string\r
-   * if nothing is found.\r
-   * @access private\r
-   * @return mixed\r
-   */\r
-  function ServerVar($varName) {\r
-    global $HTTP_SERVER_VARS;\r
-    global $HTTP_ENV_VARS;\r
-\r
-    if(!isset($_SERVER)) {\r
-      $_SERVER = $HTTP_SERVER_VARS;\r
-      if(!isset($_SERVER['REMOTE_ADDR'])) {\r
-        $_SERVER = $HTTP_ENV_VARS; // must be Apache\r
-      }\r
-    }\r
-\r
-    if(isset($_SERVER[$varName])) {\r
-      return $_SERVER[$varName];\r
-    } else {\r
-      return '';\r
-    }\r
-  }\r
-\r
-  /**\r
-   * Returns the server hostname or 'localhost.localdomain' if unknown.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function ServerHostname() {\r
-    if ($this->Hostname != '') {\r
-      $result = $this->Hostname;\r
-    } elseif ($this->ServerVar('SERVER_NAME') != '') {\r
-      $result = $this->ServerVar('SERVER_NAME');\r
-    } else {\r
-      $result = 'localhost.localdomain';\r
-    }\r
-\r
-    return $result;\r
-  }\r
-\r
-  /**\r
-   * Returns a message in the appropriate language.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function Lang($key) {\r
-    if(count($this->language) < 1) {\r
-      $this->SetLanguage('en'); // set the default language\r
-    }\r
-\r
-    if(isset($this->language[$key])) {\r
-      return $this->language[$key];\r
-    } else {\r
-      return 'Language string failed to load: ' . $key;\r
-    }\r
-  }\r
-\r
-  /**\r
-   * Returns true if an error occurred.\r
-   * @return bool\r
-   */\r
-  function IsError() {\r
-    return ($this->error_count > 0);\r
-  }\r
-\r
-  /**\r
-   * Changes every end of line from CR or LF to CRLF.\r
-   * @access private\r
-   * @return string\r
-   */\r
-  function FixEOL($str) {\r
-    $str = str_replace("\r\n", "\n", $str);\r
-    $str = str_replace("\r", "\n", $str);\r
-    $str = str_replace("\n", $this->LE, $str);\r
-    return $str;\r
-  }\r
-\r
-  /**\r
-   * Adds a custom header.\r
-   * @return void\r
-   */\r
-  function AddCustomHeader($custom_header) {\r
-    $this->CustomHeader[] = explode(':', $custom_header, 2);\r
-  }\r
-\r
-  /**\r
-   * Evaluates the message and returns modifications for inline images and backgrounds\r
-   * @access public\r
-   * @return $message\r
-   */\r
-  function MsgHTML($message) {\r
-    preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);\r
-    if(isset($images[2])) {\r
-      foreach($images[2] as $i => $url) {\r
-        $filename  = basename($url);\r
-        $directory = dirname($url);\r
-        $cid       = 'cid:' . md5($filename);\r
-        $fileParts = split("\.", $filename);\r
-        $ext       = $fileParts[1];\r
-        $mimeType  = $this->_mime_types($ext);\r
-        $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);\r
-        $this->AddEmbeddedImage($url, md5($filename), $filename, 'base64', $mimeType);\r
-      }\r
-    }\r
-    $this->IsHTML(true);\r
-    $this->Body = $message;\r
-    $textMsg = trim(strip_tags($message));\r
-    if ( !empty($textMsg) && empty($this->AltBody) ) {\r
-      $this->AltBody = $textMsg;\r
-    }\r
-    if ( empty($this->AltBody) ) {\r
-      $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";\r
-    }\r
-  }\r
-\r
-  /**\r
-   * Gets the mime type of the embedded or inline image\r
-   * @access private\r
-   * @return mime type of ext\r
-   */\r
-  function _mime_types($ext = '') {\r
-    $mimes = array(\r
-      'hqx'  =>  'application/mac-binhex40',\r
-      'cpt'   =>  'application/mac-compactpro',\r
-      'doc'   =>  'application/msword',\r
-      'bin'   =>  'application/macbinary',\r
-      'dms'   =>  'application/octet-stream',\r
-      'lha'   =>  'application/octet-stream',\r
-      'lzh'   =>  'application/octet-stream',\r
-      'exe'   =>  'application/octet-stream',\r
-      'class' =>  'application/octet-stream',\r
-      'psd'   =>  'application/octet-stream',\r
-      'so'    =>  'application/octet-stream',\r
-      'sea'   =>  'application/octet-stream',\r
-      'dll'   =>  'application/octet-stream',\r
-      'oda'   =>  'application/oda',\r
-      'pdf'   =>  'application/pdf',\r
-      'ai'    =>  'application/postscript',\r
-      'eps'   =>  'application/postscript',\r
-      'ps'    =>  'application/postscript',\r
-      'smi'   =>  'application/smil',\r
-      'smil'  =>  'application/smil',\r
-      'mif'   =>  'application/vnd.mif',\r
-      'xls'   =>  'application/vnd.ms-excel',\r
-      'ppt'   =>  'application/vnd.ms-powerpoint',\r
-      'wbxml' =>  'application/vnd.wap.wbxml',\r
-      'wmlc'  =>  'application/vnd.wap.wmlc',\r
-      'dcr'   =>  'application/x-director',\r
-      'dir'   =>  'application/x-director',\r
-      'dxr'   =>  'application/x-director',\r
-      'dvi'   =>  'application/x-dvi',\r
-      'gtar'  =>  'application/x-gtar',\r
-      'php'   =>  'application/x-httpd-php',\r
-      'php4'  =>  'application/x-httpd-php',\r
-      'php3'  =>  'application/x-httpd-php',\r
-      'phtml' =>  'application/x-httpd-php',\r
-      'phps'  =>  'application/x-httpd-php-source',\r
-      'js'    =>  'application/x-javascript',\r
-      'swf'   =>  'application/x-shockwave-flash',\r
-      'sit'   =>  'application/x-stuffit',\r
-      'tar'   =>  'application/x-tar',\r
-      'tgz'   =>  'application/x-tar',\r
-      'xhtml' =>  'application/xhtml+xml',\r
-      'xht'   =>  'application/xhtml+xml',\r
-      'zip'   =>  'application/zip',\r
-      'mid'   =>  'audio/midi',\r
-      'midi'  =>  'audio/midi',\r
-      'mpga'  =>  'audio/mpeg',\r
-      'mp2'   =>  'audio/mpeg',\r
-      'mp3'   =>  'audio/mpeg',\r
-      'aif'   =>  'audio/x-aiff',\r
-      'aiff'  =>  'audio/x-aiff',\r
-      'aifc'  =>  'audio/x-aiff',\r
-      'ram'   =>  'audio/x-pn-realaudio',\r
-      'rm'    =>  'audio/x-pn-realaudio',\r
-      'rpm'   =>  'audio/x-pn-realaudio-plugin',\r
-      'ra'    =>  'audio/x-realaudio',\r
-      'rv'    =>  'video/vnd.rn-realvideo',\r
-      'wav'   =>  'audio/x-wav',\r
-      'bmp'   =>  'image/bmp',\r
-      'gif'   =>  'image/gif',\r
-      'jpeg'  =>  'image/jpeg',\r
-      'jpg'   =>  'image/jpeg',\r
-      'jpe'   =>  'image/jpeg',\r
-      'png'   =>  'image/png',\r
-      'tiff'  =>  'image/tiff',\r
-      'tif'   =>  'image/tiff',\r
-      'css'   =>  'text/css',\r
-      'html'  =>  'text/html',\r
-      'htm'   =>  'text/html',\r
-      'shtml' =>  'text/html',\r
-      'txt'   =>  'text/plain',\r
-      'text'  =>  'text/plain',\r
-      'log'   =>  'text/plain',\r
-      'rtx'   =>  'text/richtext',\r
-      'rtf'   =>  'text/rtf',\r
-      'xml'   =>  'text/xml',\r
-      'xsl'   =>  'text/xml',\r
-      'mpeg'  =>  'video/mpeg',\r
-      'mpg'   =>  'video/mpeg',\r
-      'mpe'   =>  'video/mpeg',\r
-      'qt'    =>  'video/quicktime',\r
-      'mov'   =>  'video/quicktime',\r
-      'avi'   =>  'video/x-msvideo',\r
-      'movie' =>  'video/x-sgi-movie',\r
-      'doc'   =>  'application/msword',\r
-      'word'  =>  'application/msword',\r
-      'xl'    =>  'application/excel',\r
-      'eml'   =>  'message/rfc822'\r
-    );\r
-    return ( ! isset($mimes[strtolower($ext)])) ? 'application/x-unknown-content-type' : $mimes[strtolower($ext)];\r
-  }\r
-\r
-  /**\r
-   * Set (or reset) Class Objects (variables)\r
-   *\r
-   * Usage Example:\r
-   * $page->set('X-Priority', '3');\r
-   *\r
-   * @access public\r
-   * @param string $name Parameter Name\r
-   * @param mixed $value Parameter Value\r
-   * NOTE: will not work with arrays, there are no arrays to set/reset\r
-   */\r
-  function set ( $name, $value = '' ) {\r
-    if ( isset($this->$name) ) {\r
-      $this->$name = $value;\r
-    } else {\r
-      $this->SetError('Cannot set or reset variable ' . $name);\r
-      return false;\r
-    }\r
-  }\r
-\r
-  /**\r
-   * Read a file from a supplied filename and return it.\r
-   *\r
-   * @access public\r
-   * @param string $filename Parameter File Name\r
-   */\r
-  function getFile($filename) {\r
-    $return = '';\r
-    if ($fp = fopen($filename, 'rb')) {\r
-      while (!feof($fp)) {\r
-        $return .= fread($fp, 1024);\r
-      }\r
-      fclose($fp);\r
-      return $return;\r
-    } else {\r
-      return false;\r
-    }\r
-  }\r
-\r
-  /**\r
-   * Strips newlines to prevent header injection.\r
-   * @access private\r
-   * @param string $str String\r
-   * @return string\r
-   */\r
-  function SecureHeader($str) {\r
-    $str = trim($str);\r
-    $str = str_replace("\r", "", $str);\r
-    $str = str_replace("\n", "", $str);\r
-    return $str;\r
-  }\r
-\r
-}\r
-\r
-?>\r
+<?php
+/*~ class.phpmailer.php
+.---------------------------------------------------------------------------.
+|  Software: PHPMailer - PHP email class                                    |
+|   Version: 2.0.0 rc3                                                      |
+|   Contact: via sourceforge.net support pages (also www.codeworxtech.com)  |
+|      Info: http://phpmailer.sourceforge.net                               |
+|   Support: http://sourceforge.net/projects/phpmailer/                     |
+| ------------------------------------------------------------------------- |
+|    Author: Andy Prevost (project admininistrator)                         |
+|    Author: Brent R. Matzelle (original founder)                           |
+| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved.               |
+| Copyright (c) 2001-2003, Brent R. Matzelle                                |
+| ------------------------------------------------------------------------- |
+|   License: Distributed under the Lesser General Public License (LGPL)     |
+|            http://www.gnu.org/copyleft/lesser.html                        |
+| This program is distributed in the hope that it will be useful - WITHOUT  |
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     |
+| FITNESS FOR A PARTICULAR PURPOSE.                                         |
+| ------------------------------------------------------------------------- |
+| We offer a number of paid services (www.codeworxtech.com):                |
+| - Web Hosting on highly optimized fast and secure servers                 |
+| - Technology Consulting                                                   |
+| - Oursourcing (highly qualified programmers and graphic designers)        |
+'---------------------------------------------------------------------------'
+
+/**
+ * PHPMailer - PHP email transport class
+ * @package PHPMailer
+ * @author Andy Prevost
+ * @copyright 2004 - 2007 Andy Prevost
+ */
+
+class PHPMailer {
+
+  /////////////////////////////////////////////////
+  // PROPERTIES, PUBLIC
+  /////////////////////////////////////////////////
+
+  /**
+   * Email priority (1 = High, 3 = Normal, 5 = low).
+   * @var int
+   */
+  var $Priority          = 3;
+
+  /**
+   * Sets the CharSet of the message.
+   * @var string
+   */
+  var $CharSet           = 'iso-8859-1';
+
+  /**
+   * Sets the Content-type of the message.
+   * @var string
+   */
+  var $ContentType        = 'text/plain';
+
+  /**
+   * Sets the Encoding of the message. Options for this are "8bit",
+   * "7bit", "binary", "base64", and "quoted-printable".
+   * @var string
+   */
+  var $Encoding          = '8bit';
+
+  /**
+   * Holds the most recent mailer error message.
+   * @var string
+   */
+  var $ErrorInfo         = '';
+
+  /**
+   * Sets the From email address for the message.
+   * @var string
+   */
+  var $From              = 'root@localhost';
+
+  /**
+   * Sets the From name of the message.
+   * @var string
+   */
+  var $FromName          = 'Root User';
+
+  /**
+   * Sets the Sender email (Return-Path) of the message.  If not empty,
+   * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
+   * @var string
+   */
+  var $Sender            = '';
+
+  /**
+   * Sets the Subject of the message.
+   * @var string
+   */
+  var $Subject           = '';
+
+  /**
+   * Sets the Body of the message.  This can be either an HTML or text body.
+   * If HTML then run IsHTML(true).
+   * @var string
+   */
+  var $Body              = '';
+
+  /**
+   * Sets the text-only body of the message.  This automatically sets the
+   * email to multipart/alternative.  This body can be read by mail
+   * clients that do not have HTML email capability such as mutt. Clients
+   * that can read HTML will view the normal Body.
+   * @var string
+   */
+  var $AltBody           = '';
+
+  /**
+   * Sets word wrapping on the body of the message to a given number of
+   * characters.
+   * @var int
+   */
+  var $WordWrap          = 0;
+
+  /**
+   * Method to send mail: ("mail", "sendmail", or "smtp").
+   * @var string
+   */
+  var $Mailer            = 'mail';
+
+  /**
+   * Sets the path of the sendmail program.
+   * @var string
+   */
+  var $Sendmail          = '/usr/sbin/sendmail';
+
+  /**
+   * Path to PHPMailer plugins.  This is now only useful if the SMTP class
+   * is in a different directory than the PHP include path.
+   * @var string
+   */
+  var $PluginDir         = '';
+
+  /**
+   * Holds PHPMailer version.
+   * @var string
+   */
+  var $Version           = "2.0.0 rc3";
+
+  /**
+   * Sets the email address that a reading confirmation will be sent.
+   * @var string
+   */
+  var $ConfirmReadingTo  = '';
+
+  /**
+   * Sets the hostname to use in Message-Id and Received headers
+   * and as default HELO string. If empty, the value returned
+   * by SERVER_NAME is used or 'localhost.localdomain'.
+   * @var string
+   */
+  var $Hostname          = '';
+
+  /////////////////////////////////////////////////
+  // PROPERTIES FOR SMTP
+  /////////////////////////////////////////////////
+
+  /**
+   * Sets the SMTP hosts.  All hosts must be separated by a
+   * semicolon.  You can also specify a different port
+   * for each host by using this format: [hostname:port]
+   * (e.g. "smtp1.example.com:25;smtp2.example.com").
+   * Hosts will be tried in order.
+   * @var string
+   */
+  var $Host        = 'localhost';
+
+  /**
+   * Sets the default SMTP server port.
+   * @var int
+   */
+  var $Port        = 25;
+
+  /**
+   * Sets the SMTP HELO of the message (Default is $Hostname).
+   * @var string
+   */
+  var $Helo        = '';
+
+  /**
+   * Sets connection prefix.
+   * Options are "", "ssl" or "tls"
+   * @var string
+   */
+  var $SMTPSecure = "";
+
+  /**
+   * Sets SMTP authentication. Utilizes the Username and Password variables.
+   * @var bool
+   */
+  var $SMTPAuth     = false;
+
+  /**
+   * Sets SMTP username.
+   * @var string
+   */
+  var $Username     = '';
+
+  /**
+   * Sets SMTP password.
+   * @var string
+   */
+  var $Password     = '';
+
+  /**
+   * Sets the SMTP server timeout in seconds. This function will not
+   * work with the win32 version.
+   * @var int
+   */
+  var $Timeout      = 10;
+
+  /**
+   * Sets SMTP class debugging on or off.
+   * @var bool
+   */
+  var $SMTPDebug    = false;
+
+  /**
+   * Prevents the SMTP connection from being closed after each mail
+   * sending.  If this is set to true then to close the connection
+   * requires an explicit call to SmtpClose().
+   * @var bool
+   */
+  var $SMTPKeepAlive = false;
+
+  /**
+   * Provides the ability to have the TO field process individual
+   * emails, instead of sending to entire TO addresses
+   * @var bool
+   */
+  var $SingleTo = false;
+
+  /////////////////////////////////////////////////
+  // PROPERTIES, PRIVATE
+  /////////////////////////////////////////////////
+
+  var $smtp            = NULL;
+  var $to              = array();
+  var $cc              = array();
+  var $bcc             = array();
+  var $ReplyTo         = array();
+  var $attachment      = array();
+  var $CustomHeader    = array();
+  var $message_type    = '';
+  var $boundary        = array();
+  var $language        = array();
+  var $error_count     = 0;
+  var $LE              = "\n";
+
+  /////////////////////////////////////////////////
+  // METHODS, VARIABLES
+  /////////////////////////////////////////////////
+
+  /**
+   * Sets message type to HTML.
+   * @param bool $bool
+   * @return void
+   */
+  function IsHTML($bool) {
+    if($bool == true) {
+      $this->ContentType = 'text/html';
+    } else {
+      $this->ContentType = 'text/plain';
+    }
+  }
+
+  /**
+   * Sets Mailer to send message using SMTP.
+   * @return void
+   */
+  function IsSMTP() {
+    $this->Mailer = 'smtp';
+  }
+
+  /**
+   * Sets Mailer to send message using PHP mail() function.
+   * @return void
+   */
+  function IsMail() {
+    $this->Mailer = 'mail';
+  }
+
+  /**
+   * Sets Mailer to send message using the $Sendmail program.
+   * @return void
+   */
+  function IsSendmail() {
+    $this->Mailer = 'sendmail';
+  }
+
+  /**
+   * Sets Mailer to send message using the qmail MTA.
+   * @return void
+   */
+  function IsQmail() {
+    $this->Sendmail = '/var/qmail/bin/sendmail';
+    $this->Mailer = 'sendmail';
+  }
+
+  /////////////////////////////////////////////////
+  // METHODS, RECIPIENTS
+  /////////////////////////////////////////////////
+
+  /**
+   * Adds a "To" address.
+   * @param string $address
+   * @param string $name
+   * @return void
+   */
+  function AddAddress($address, $name = '') {
+    $cur = count($this->to);
+    $this->to[$cur][0] = trim($address);
+    $this->to[$cur][1] = $name;
+  }
+
+  /**
+   * Adds a "Cc" address. Note: this function works
+   * with the SMTP mailer on win32, not with the "mail"
+   * mailer.
+   * @param string $address
+   * @param string $name
+   * @return 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.
+   * @param string $address
+   * @param string $name
+   * @return 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.
+   * @param string $address
+   * @param string $name
+   * @return void
+   */
+  function AddReplyTo($address, $name = '') {
+    $cur = count($this->ReplyTo);
+    $this->ReplyTo[$cur][0] = trim($address);
+    $this->ReplyTo[$cur][1] = $name;
+  }
+
+  /////////////////////////////////////////////////
+  // METHODS, MAIL SENDING
+  /////////////////////////////////////////////////
+
+  /**
+   * Creates message and assigns Mailer. If the message is
+   * not sent successfully then it returns false.  Use the ErrorInfo
+   * variable to view description of the error.
+   * @return bool
+   */
+  function Send() {
+    $header = '';
+    $body = '';
+    $result = true;
+
+    if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
+      $this->SetError($this->Lang('provide_address'));
+      return false;
+    }
+
+    /* Set whether the message is multipart/alternative */
+    if(!empty($this->AltBody)) {
+      $this->ContentType = 'multipart/alternative';
+    }
+
+    $this->error_count = 0; // reset errors
+    $this->SetMessageType();
+    $header .= $this->CreateHeader();
+    $body = $this->CreateBody();
+
+    if($body == '') {
+      return false;
+    }
+
+    /* Choose the mailer */
+    switch($this->Mailer) {
+      case 'sendmail':
+        $result = $this->SendmailSend($header, $body);
+        break;
+      case 'smtp':
+        $result = $this->SmtpSend($header, $body);
+        break;
+      case 'mail':
+        $result = $this->MailSend($header, $body);
+        break;
+      default:
+        $result = $this->MailSend($header, $body);
+        break;
+        //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));
+        //$result = false;
+        //break;
+    }
+
+    return $result;
+  }
+
+  /**
+   * Sends mail using the $Sendmail program.
+   * @access private
+   * @return bool
+   */
+  function SendmailSend($header, $body) {
+    if ($this->Sender != '') {
+      $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
+    } else {
+      $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
+    }
+
+    if(!@$mail = popen($sendmail, 'w')) {
+      $this->SetError($this->Lang('execute') . $this->Sendmail);
+      return false;
+    }
+
+    fputs($mail, $header);
+    fputs($mail, $body);
+
+    $result = pclose($mail) >> 8 & 0xFF;
+    if($result != 0) {
+      $this->SetError($this->Lang('execute') . $this->Sendmail);
+      return false;
+    }
+
+    return true;
+  }
+
+  /**
+   * Sends mail using the PHP mail() function.
+   * @access private
+   * @return bool
+   */
+  function MailSend($header, $body) {
+
+    $to = '';
+    for($i = 0; $i < count($this->to); $i++) {
+      if($i != 0) { $to .= ', '; }
+      $to .= $this->AddrFormat($this->to[$i]);
+    }
+
+    $toArr = split(',', $to);
+
+    if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
+      $old_from = ini_get('sendmail_from');
+      ini_set('sendmail_from', $this->Sender);
+      $params = sprintf("-oi -f %s", $this->Sender);
+      if ($this->SingleTo === true && count($toArr) > 1) {
+        foreach ($toArr as $key => $val) {
+          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+        }
+      } else {
+        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+      }
+    } else {
+      if ($this->SingleTo === true && count($toArr) > 1) {
+        foreach ($toArr as $key => $val) {
+          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+        }
+      } else {
+        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
+      }
+    }
+
+    if (isset($old_from)) {
+      ini_set('sendmail_from', $old_from);
+    }
+
+    if(!$rt) {
+      $this->SetError($this->Lang('instantiate'));
+      return false;
+    }
+
+    return true;
+  }
+
+  /**
+   * Sends mail via SMTP using PhpSMTP (Author:
+   * Chris Ryan).  Returns bool.  Returns false if there is a
+   * bad MAIL FROM, RCPT, or DATA input.
+   * @access private
+   * @return bool
+   */
+  function SmtpSend($header, $body) {
+    include_once($this->PluginDir . 'class.smtp.php');
+    $error = '';
+    $bad_rcpt = array();
+
+    if(!$this->SmtpConnect()) {
+      return false;
+    }
+
+    $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
+    if(!$this->smtp->Mail($smtp_from)) {
+      $error = $this->Lang('from_failed') . $smtp_from;
+      $this->SetError($error);
+      $this->smtp->Reset();
+      return false;
+    }
+
+    /* Attempt to send attach all recipients */
+    for($i = 0; $i < count($this->to); $i++) {
+      if(!$this->smtp->Recipient($this->to[$i][0])) {
+        $bad_rcpt[] = $this->to[$i][0];
+      }
+    }
+    for($i = 0; $i < count($this->cc); $i++) {
+      if(!$this->smtp->Recipient($this->cc[$i][0])) {
+        $bad_rcpt[] = $this->cc[$i][0];
+      }
+    }
+    for($i = 0; $i < count($this->bcc); $i++) {
+      if(!$this->smtp->Recipient($this->bcc[$i][0])) {
+        $bad_rcpt[] = $this->bcc[$i][0];
+      }
+    }
+
+    if(count($bad_rcpt) > 0) { // Create error message
+      for($i = 0; $i < count($bad_rcpt); $i++) {
+        if($i != 0) {
+          $error .= ', ';
+        }
+        $error .= $bad_rcpt[$i];
+      }
+      $error = $this->Lang('recipients_failed') . $error;
+      $this->SetError($error);
+      $this->smtp->Reset();
+      return false;
+    }
+
+    if(!$this->smtp->Data($header . $body)) {
+      $this->SetError($this->Lang('data_not_accepted'));
+      $this->smtp->Reset();
+      return false;
+    }
+    if($this->SMTPKeepAlive == true) {
+      $this->smtp->Reset();
+    } else {
+      $this->SmtpClose();
+    }
+
+    return true;
+  }
+
+  /**
+   * Initiates a connection to an SMTP server.  Returns false if the
+   * operation failed.
+   * @access private
+   * @return bool
+   */
+  function SmtpConnect() {
+    if($this->smtp == NULL) {
+      $this->smtp = new SMTP();
+    }
+
+    $this->smtp->do_debug = $this->SMTPDebug;
+    $hosts = explode(';', $this->Host);
+    $index = 0;
+    $connection = ($this->smtp->Connected());
+
+    /* Retry while there is no connection */
+    while($index < count($hosts) && $connection == false) {
+      $hostinfo = array();
+      if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {
+        $host = $hostinfo[1];
+        $port = $hostinfo[2];
+      } else {
+        $host = $hosts[$index];
+        $port = $this->Port;
+      }
+
+      if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) {
+        if ($this->Helo != '') {
+          $this->smtp->Hello($this->Helo);
+        } else {
+          $this->smtp->Hello($this->ServerHostname());
+        }
+
+        $connection = true;
+        if($this->SMTPAuth) {
+          if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
+            $this->SetError($this->Lang('authenticate'));
+            $this->smtp->Reset();
+            $connection = false;
+          }
+        }
+      }
+      $index++;
+    }
+    if(!$connection) {
+      $this->SetError($this->Lang('connect_host'));
+    }
+
+    return $connection;
+  }
+
+  /**
+   * Closes the active SMTP session if one exists.
+   * @return void
+   */
+  function SmtpClose() {
+    if($this->smtp != NULL) {
+      if($this->smtp->Connected()) {
+        $this->smtp->Quit();
+        $this->smtp->Close();
+      }
+    }
+  }
+
+  /**
+   * Sets the language for all class error messages.  Returns false
+   * if it cannot load the language file.  The default language type
+   * is English.
+   * @param string $lang_type Type of language (e.g. Portuguese: "br")
+   * @param string $lang_path Path to the language file directory
+   * @access public
+   * @return bool
+   */
+  function SetLanguage($lang_type, $lang_path = 'language/') {
+    if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) {
+      include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
+    } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) {
+      include($lang_path.'phpmailer.lang-en.php');
+    } else {
+      $this->SetError('Could not load language file');
+      return false;
+    }
+    $this->language = $PHPMAILER_LANG;
+
+    return true;
+  }
+
+  /////////////////////////////////////////////////
+  // METHODS, MESSAGE CREATION
+  /////////////////////////////////////////////////
+
+  /**
+   * Creates recipient headers.
+   * @access private
+   * @return string
+   */
+  function AddrAppend($type, $addr) {
+    $addr_str = $type . ': ';
+    $addr_str .= $this->AddrFormat($addr[0]);
+    if(count($addr) > 1) {
+      for($i = 1; $i < count($addr); $i++) {
+        $addr_str .= ', ' . $this->AddrFormat($addr[$i]);
+      }
+    }
+    $addr_str .= $this->LE;
+
+    return $addr_str;
+  }
+
+  /**
+   * Formats an address correctly.
+   * @access private
+   * @return string
+   */
+  function AddrFormat($addr) {
+    if(empty($addr[1])) {
+      $formatted = $this->SecureHeader($addr[0]);
+    } else {
+      $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
+    }
+
+    return $formatted;
+  }
+
+  /**
+   * Wraps message for use with mailers that do not
+   * automatically perform wrapping and for quoted-printable.
+   * Original written by philippe.
+   * @access private
+   * @return string
+   */
+  function WrapText($message, $length, $qp_mode = false) {
+    $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
+
+    $message = $this->FixEOL($message);
+    if (substr($message, -1) == $this->LE) {
+      $message = substr($message, 0, -1);
+    }
+
+    $line = explode($this->LE, $message);
+    $message = '';
+    for ($i=0 ;$i < count($line); $i++) {
+      $line_part = explode(' ', $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 . sprintf("=%s", $this->LE);
+            } 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 . sprintf("=%s", $this->LE);
+            } else {
+              $buf = $part;
+            }
+          }
+        } else {
+          $buf_o = $buf;
+          $buf .= ($e == 0) ? $word : (' ' . $word);
+
+          if (strlen($buf) > $length and $buf_o != '') {
+            $message .= $buf_o . $soft_break;
+            $buf = $word;
+          }
+        }
+      }
+      $message .= $buf . $this->LE;
+    }
+
+    return $message;
+  }
+
+  /**
+   * Set the body wrapping.
+   * @access private
+   * @return void
+   */
+  function SetWordWrap() {
+    if($this->WordWrap < 1) {
+      return;
+    }
+
+    switch($this->message_type) {
+      case 'alt':
+        /* fall through */
+      case 'alt_attachments':
+        $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
+        break;
+      default:
+        $this->Body = $this->WrapText($this->Body, $this->WordWrap);
+        break;
+    }
+  }
+
+  /**
+   * Assembles message header.
+   * @access private
+   * @return string
+   */
+  function CreateHeader() {
+    $result = '';
+
+    /* Set the boundaries */
+    $uniq_id = md5(uniqid(time()));
+    $this->boundary[1] = 'b1_' . $uniq_id;
+    $this->boundary[2] = 'b2_' . $uniq_id;
+
+    $result .= $this->HeaderLine('Date', $this->RFCDate());
+    if($this->Sender == '') {
+      $result .= $this->HeaderLine('Return-Path', trim($this->From));
+    } else {
+      $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
+    }
+
+    /* To be created automatically by mail() */
+    if($this->Mailer != 'mail') {
+      if(count($this->to) > 0) {
+        $result .= $this->AddrAppend('To', $this->to);
+      } elseif (count($this->cc) == 0) {
+        $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
+      }
+      if(count($this->cc) > 0) {
+        $result .= $this->AddrAppend('Cc', $this->cc);
+      }
+    }
+
+    $from = array();
+    $from[0][0] = trim($this->From);
+    $from[0][1] = $this->FromName;
+    $result .= $this->AddrAppend('From', $from);
+
+    /* sendmail and mail() extract Cc from the header before sending */
+    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {
+      $result .= $this->AddrAppend('Cc', $this->cc);
+    }
+
+    /* sendmail and mail() extract Bcc from the header before sending */
+    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
+      $result .= $this->AddrAppend('Bcc', $this->bcc);
+    }
+
+    if(count($this->ReplyTo) > 0) {
+      $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
+    }
+
+    /* mail() sets the subject itself */
+    if($this->Mailer != 'mail') {
+      $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
+    }
+
+    $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
+    $result .= $this->HeaderLine('X-Priority', $this->Priority);
+    $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']');
+
+    if($this->ConfirmReadingTo != '') {
+      $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
+    }
+
+    // Add custom headers
+    for($index = 0; $index < count($this->CustomHeader); $index++) {
+      $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
+    }
+    $result .= $this->HeaderLine('MIME-Version', '1.0');
+
+    switch($this->message_type) {
+      case 'plain':
+        $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
+        $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
+        break;
+      case 'attachments':
+        /* fall through */
+      case 'alt_attachments':
+        if($this->InlineImageExists()){
+          $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
+        } else {
+          $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
+          $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+        }
+        break;
+      case 'alt':
+        $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
+        $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+        break;
+    }
+
+    if($this->Mailer != 'mail') {
+      $result .= $this->LE.$this->LE;
+    }
+
+    return $result;
+  }
+
+  /**
+   * Assembles the message body.  Returns an empty string on failure.
+   * @access private
+   * @return string
+   */
+  function CreateBody() {
+    $result = '';
+
+    $this->SetWordWrap();
+
+    switch($this->message_type) {
+      case 'alt':
+        $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
+        $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+        $result .= $this->LE.$this->LE;
+        $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
+        $result .= $this->EncodeString($this->Body, $this->Encoding);
+        $result .= $this->LE.$this->LE;
+        $result .= $this->EndBoundary($this->boundary[1]);
+        break;
+      case 'plain':
+        $result .= $this->EncodeString($this->Body, $this->Encoding);
+        break;
+      case 'attachments':
+        $result .= $this->GetBoundary($this->boundary[1], '', '', '');
+        $result .= $this->EncodeString($this->Body, $this->Encoding);
+        $result .= $this->LE;
+        $result .= $this->AttachAll();
+        break;
+      case 'alt_attachments':
+        $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
+        $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
+        $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
+        $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+        $result .= $this->LE.$this->LE;
+        $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
+        $result .= $this->EncodeString($this->Body, $this->Encoding);
+        $result .= $this->LE.$this->LE;
+        $result .= $this->EndBoundary($this->boundary[2]);
+        $result .= $this->AttachAll();
+        break;
+    }
+    if($this->IsError()) {
+      $result = '';
+    }
+
+    return $result;
+  }
+
+  /**
+   * Returns the start of a message boundary.
+   * @access private
+   */
+  function GetBoundary($boundary, $charSet, $contentType, $encoding) {
+    $result = '';
+    if($charSet == '') {
+      $charSet = $this->CharSet;
+    }
+    if($contentType == '') {
+      $contentType = $this->ContentType;
+    }
+    if($encoding == '') {
+      $encoding = $this->Encoding;
+    }
+    $result .= $this->TextLine('--' . $boundary);
+    $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
+    $result .= $this->LE;
+    $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
+    $result .= $this->LE;
+
+    return $result;
+  }
+
+  /**
+   * Returns the end of a message boundary.
+   * @access private
+   */
+  function EndBoundary($boundary) {
+    return $this->LE . '--' . $boundary . '--' . $this->LE;
+  }
+
+  /**
+   * Sets the message type.
+   * @access private
+   * @return void
+   */
+  function SetMessageType() {
+    if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
+      $this->message_type = 'plain';
+    } else {
+      if(count($this->attachment) > 0) {
+        $this->message_type = 'attachments';
+      }
+      if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
+        $this->message_type = 'alt';
+      }
+      if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
+        $this->message_type = 'alt_attachments';
+      }
+    }
+  }
+
+  /* Returns a formatted header line.
+   * @access private
+   * @return string
+   */
+  function HeaderLine($name, $value) {
+    return $name . ': ' . $value . $this->LE;
+  }
+
+  /**
+   * Returns a formatted mail line.
+   * @access private
+   * @return string
+   */
+  function TextLine($value) {
+    return $value . $this->LE;
+  }
+
+  /////////////////////////////////////////////////
+  // CLASS METHODS, ATTACHMENTS
+  /////////////////////////////////////////////////
+
+  /**
+   * Adds an attachment from a path on the filesystem.
+   * Returns false if the file could not be found
+   * or accessed.
+   * @param string $path Path to the attachment.
+   * @param string $name Overrides the attachment name.
+   * @param string $encoding File encoding (see $Encoding).
+   * @param string $type File extension (MIME) type.
+   * @return bool
+   */
+  function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
+    if(!@is_file($path)) {
+      $this->SetError($this->Lang('file_access') . $path);
+      return false;
+    }
+
+    $filename = basename($path);
+    if($name == '') {
+      $name = $filename;
+    }
+
+    $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;
+    $this->attachment[$cur][5] = false; // isStringAttachment
+    $this->attachment[$cur][6] = 'attachment';
+    $this->attachment[$cur][7] = 0;
+
+    return true;
+  }
+
+  /**
+   * Attaches all fs, string, and binary attachments to the message.
+   * Returns an empty string on failure.
+   * @access private
+   * @return string
+   */
+  function AttachAll() {
+    /* Return text of body */
+    $mime = array();
+
+    /* Add all attachments */
+    for($i = 0; $i < count($this->attachment); $i++) {
+      /* Check for string attachment */
+      $bString = $this->attachment[$i][5];
+      if ($bString) {
+        $string = $this->attachment[$i][0];
+      } else {
+        $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];
+      $disposition = $this->attachment[$i][6];
+      $cid         = $this->attachment[$i][7];
+
+      $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
+      $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
+      $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
+
+      if($disposition == 'inline') {
+        $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
+      }
+
+      $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE);
+
+      /* Encode as string attachment */
+      if($bString) {
+        $mime[] = $this->EncodeString($string, $encoding);
+        if($this->IsError()) {
+          return '';
+        }
+        $mime[] = $this->LE.$this->LE;
+      } else {
+        $mime[] = $this->EncodeFile($path, $encoding);
+        if($this->IsError()) {
+          return '';
+        }
+        $mime[] = $this->LE.$this->LE;
+      }
+    }
+
+    $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
+
+    return join('', $mime);
+  }
+
+  /**
+   * Encodes attachment in requested format.  Returns an
+   * empty string on failure.
+   * @access private
+   * @return string
+   */
+  function EncodeFile ($path, $encoding = 'base64') {
+    if(!@$fd = fopen($path, 'rb')) {
+      $this->SetError($this->Lang('file_open') . $path);
+      return '';
+    }
+    $magic_quotes = get_magic_quotes_runtime();
+    set_magic_quotes_runtime(0);
+    $file_buffer = fread($fd, filesize($path));
+    $file_buffer = $this->EncodeString($file_buffer, $encoding);
+    fclose($fd);
+    set_magic_quotes_runtime($magic_quotes);
+
+    return $file_buffer;
+  }
+
+  /**
+   * Encodes string to requested format. Returns an
+   * empty string on failure.
+   * @access private
+   * @return string
+   */
+  function EncodeString ($str, $encoding = 'base64') {
+    $encoded = '';
+    switch(strtolower($encoding)) {
+      case 'base64':
+        /* chunk_split is found in PHP >= 3.0.6 */
+        $encoded = chunk_split(base64_encode($str), 76, $this->LE);
+        break;
+      case '7bit':
+      case '8bit':
+        $encoded = $this->FixEOL($str);
+        if (substr($encoded, -(strlen($this->LE))) != $this->LE)
+          $encoded .= $this->LE;
+        break;
+      case 'binary':
+        $encoded = $str;
+        break;
+      case 'quoted-printable':
+        $encoded = $this->EncodeQP($str);
+        break;
+      default:
+        $this->SetError($this->Lang('encoding') . $encoding);
+        break;
+    }
+    return $encoded;
+  }
+
+  /**
+   * Encode a header string to best of Q, B, quoted or none.
+   * @access private
+   * @return string
+   */
+  function EncodeHeader ($str, $position = 'text') {
+    $x = 0;
+
+    switch (strtolower($position)) {
+      case 'phrase':
+        if (!preg_match('/[\200-\377]/', $str)) {
+          /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */
+          $encoded = addcslashes($str, "\0..\37\177\\\"");
+          if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
+            return ($encoded);
+          } else {
+            return ("\"$encoded\"");
+          }
+        }
+        $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
+        break;
+      case 'comment':
+        $x = preg_match_all('/[()"]/', $str, $matches);
+        /* Fall-through */
+      case 'text':
+      default:
+        $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
+        break;
+    }
+
+    if ($x == 0) {
+      return ($str);
+    }
+
+    $maxlen = 75 - 7 - strlen($this->CharSet);
+    /* Try to select the encoding which should produce the shortest output */
+    if (strlen($str)/3 < $x) {
+      $encoding = 'B';
+      $encoded = base64_encode($str);
+      $maxlen -= $maxlen % 4;
+      $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
+    } else {
+      $encoding = 'Q';
+      $encoded = $this->EncodeQ($str, $position);
+      $encoded = $this->WrapText($encoded, $maxlen, true);
+      $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
+    }
+
+    $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
+    $encoded = trim(str_replace("\n", $this->LE, $encoded));
+
+    return $encoded;
+  }
+
+  /**
+   * Encode string to quoted-printable.
+   * @access private
+   * @return string
+   */
+  function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {
+    $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
+    $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
+    $eol = "\r\n";
+    $escape = '=';
+    $output = '';
+    while( list(, $line) = each($lines) ) {
+      $linlen = strlen($line);
+      $newline = '';
+      for($i = 0; $i < $linlen; $i++) {
+        $c = substr( $line, $i, 1 );
+        $dec = ord( $c );
+        if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
+          $c = '=2E';
+        }
+        if ( $dec == 32 ) {
+          if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
+            $c = '=20';
+          } else if ( $space_conv ) {
+            $c = '=20';
+          }
+        } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
+          $h2 = floor($dec/16);
+          $h1 = floor($dec%16);
+          $c = $escape.$hex[$h2].$hex[$h1];
+        }
+        if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
+          $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
+          $newline = '';
+          // check if newline first character will be point or not
+          if ( $dec == 46 ) {
+            $c = '=2E';
+          }
+        }
+        $newline .= $c;
+      } // end of for
+      $output .= $newline.$eol;
+    } // end of while
+    return trim($output);
+  }
+
+  /**
+   * Encode string to q encoding.
+   * @access private
+   * @return string
+   */
+  function EncodeQ ($str, $position = 'text') {
+    /* There should not be any EOL in the string */
+    $encoded = preg_replace("[\r\n]", '', $str);
+
+    switch (strtolower($position)) {
+      case 'phrase':
+        $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+        break;
+      case 'comment':
+        $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+      case 'text':
+      default:
+        /* Replace every high ascii, control =, ? and _ characters */
+        $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
+              "'='.sprintf('%02X', ord('\\1'))", $encoded);
+        break;
+    }
+
+    /* Replace every spaces to _ (more readable than =20) */
+    $encoded = str_replace(' ', '_', $encoded);
+
+    return $encoded;
+  }
+
+  /**
+   * Adds a string or binary attachment (non-filesystem) to the list.
+   * This method can be used to attach ascii or binary data,
+   * such as a BLOB record from a database.
+   * @param string $string String attachment data.
+   * @param string $filename Name of the attachment.
+   * @param string $encoding File encoding (see $Encoding).
+   * @param string $type File extension (MIME) type.
+   * @return void
+   */
+  function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
+    /* Append to $attachment array */
+    $cur = count($this->attachment);
+    $this->attachment[$cur][0] = $string;
+    $this->attachment[$cur][1] = $filename;
+    $this->attachment[$cur][2] = $filename;
+    $this->attachment[$cur][3] = $encoding;
+    $this->attachment[$cur][4] = $type;
+    $this->attachment[$cur][5] = true; // isString
+    $this->attachment[$cur][6] = 'attachment';
+    $this->attachment[$cur][7] = 0;
+  }
+
+  /**
+   * Adds an embedded attachment.  This can include images, sounds, and
+   * just about any other document.  Make sure to set the $type to an
+   * image type.  For JPEG images use "image/jpeg" and for GIF images
+   * use "image/gif".
+   * @param string $path Path to the attachment.
+   * @param string $cid Content ID of the attachment.  Use this to identify
+   *        the Id for accessing the image in an HTML form.
+   * @param string $name Overrides the attachment name.
+   * @param string $encoding File encoding (see $Encoding).
+   * @param string $type File extension (MIME) type.
+   * @return bool
+   */
+  function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
+
+    if(!@is_file($path)) {
+      $this->SetError($this->Lang('file_access') . $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;
+    $this->attachment[$cur][5] = false;
+    $this->attachment[$cur][6] = 'inline';
+    $this->attachment[$cur][7] = $cid;
+
+    return true;
+  }
+
+  /**
+   * Returns true if an inline attachment is present.
+   * @access private
+   * @return bool
+   */
+  function InlineImageExists() {
+    $result = false;
+    for($i = 0; $i < count($this->attachment); $i++) {
+      if($this->attachment[$i][6] == 'inline') {
+        $result = true;
+        break;
+      }
+    }
+
+    return $result;
+  }
+
+  /////////////////////////////////////////////////
+  // CLASS METHODS, MESSAGE RESET
+  /////////////////////////////////////////////////
+
+  /**
+   * Clears all recipients assigned in the TO array.  Returns void.
+   * @return void
+   */
+  function ClearAddresses() {
+    $this->to = array();
+  }
+
+  /**
+   * Clears all recipients assigned in the CC array.  Returns void.
+   * @return void
+   */
+  function ClearCCs() {
+    $this->cc = array();
+  }
+
+  /**
+   * Clears all recipients assigned in the BCC array.  Returns void.
+   * @return void
+   */
+  function ClearBCCs() {
+    $this->bcc = array();
+  }
+
+  /**
+   * Clears all recipients assigned in the ReplyTo array.  Returns void.
+   * @return void
+   */
+  function ClearReplyTos() {
+    $this->ReplyTo = array();
+  }
+
+  /**
+   * Clears all recipients assigned in the TO, CC and BCC
+   * array.  Returns void.
+   * @return void
+   */
+  function ClearAllRecipients() {
+    $this->to = array();
+    $this->cc = array();
+    $this->bcc = array();
+  }
+
+  /**
+   * Clears all previously set filesystem, string, and binary
+   * attachments.  Returns void.
+   * @return void
+   */
+  function ClearAttachments() {
+    $this->attachment = array();
+  }
+
+  /**
+   * Clears all custom headers.  Returns void.
+   * @return void
+   */
+  function ClearCustomHeaders() {
+    $this->CustomHeader = array();
+  }
+
+  /////////////////////////////////////////////////
+  // CLASS METHODS, MISCELLANEOUS
+  /////////////////////////////////////////////////
+
+  /**
+   * Adds the error message to the error container.
+   * Returns void.
+   * @access private
+   * @return void
+   */
+  function SetError($msg) {
+    $this->error_count++;
+    $this->ErrorInfo = $msg;
+  }
+
+  /**
+   * Returns the proper RFC 822 formatted date.
+   * @access private
+   * @return string
+   */
+  function RFCDate() {
+    $tz = date('Z');
+    $tzs = ($tz < 0) ? '-' : '+';
+    $tz = abs($tz);
+    $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
+    $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
+
+    return $result;
+  }
+
+  /**
+   * Returns the appropriate server variable.  Should work with both
+   * PHP 4.1.0+ as well as older versions.  Returns an empty string
+   * if nothing is found.
+   * @access private
+   * @return mixed
+   */
+  function ServerVar($varName) {
+    global $HTTP_SERVER_VARS;
+    global $HTTP_ENV_VARS;
+
+    if(!isset($_SERVER)) {
+      $_SERVER = $HTTP_SERVER_VARS;
+      if(!isset($_SERVER['REMOTE_ADDR'])) {
+        $_SERVER = $HTTP_ENV_VARS; // must be Apache
+      }
+    }
+
+    if(isset($_SERVER[$varName])) {
+      return $_SERVER[$varName];
+    } else {
+      return '';
+    }
+  }
+
+  /**
+   * Returns the server hostname or 'localhost.localdomain' if unknown.
+   * @access private
+   * @return string
+   */
+  function ServerHostname() {
+    if ($this->Hostname != '') {
+      $result = $this->Hostname;
+    } elseif ($this->ServerVar('SERVER_NAME') != '') {
+      $result = $this->ServerVar('SERVER_NAME');
+    } else {
+      $result = 'localhost.localdomain';
+    }
+
+    return $result;
+  }
+
+  /**
+   * Returns a message in the appropriate language.
+   * @access private
+   * @return string
+   */
+  function Lang($key) {
+    if(count($this->language) < 1) {
+      $this->SetLanguage('en'); // set the default language
+    }
+
+    if(isset($this->language[$key])) {
+      return $this->language[$key];
+    } else {
+      return 'Language string failed to load: ' . $key;
+    }
+  }
+
+  /**
+   * Returns true if an error occurred.
+   * @return bool
+   */
+  function IsError() {
+    return ($this->error_count > 0);
+  }
+
+  /**
+   * Changes every end of line from CR or LF to CRLF.
+   * @access private
+   * @return string
+   */
+  function FixEOL($str) {
+    $str = str_replace("\r\n", "\n", $str);
+    $str = str_replace("\r", "\n", $str);
+    $str = str_replace("\n", $this->LE, $str);
+    return $str;
+  }
+
+  /**
+   * Adds a custom header.
+   * @return void
+   */
+  function AddCustomHeader($custom_header) {
+    $this->CustomHeader[] = explode(':', $custom_header, 2);
+  }
+
+  /**
+   * Evaluates the message and returns modifications for inline images and backgrounds
+   * @access public
+   * @return $message
+   */
+  function MsgHTML($message) {
+    preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
+    if(isset($images[2])) {
+      foreach($images[2] as $i => $url) {
+        $filename  = basename($url);
+        $directory = dirname($url);
+        $cid       = 'cid:' . md5($filename);
+        $fileParts = split("\.", $filename);
+        $ext       = $fileParts[1];
+        $mimeType  = $this->_mime_types($ext);
+        $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
+        $this->AddEmbeddedImage($url, md5($filename), $filename, 'base64', $mimeType);
+      }
+    }
+    $this->IsHTML(true);
+    $this->Body = $message;
+    $textMsg = trim(strip_tags($message));
+    if ( !empty($textMsg) && empty($this->AltBody) ) {
+      $this->AltBody = $textMsg;
+    }
+    if ( empty($this->AltBody) ) {
+      $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";
+    }
+  }
+
+  /**
+   * Gets the mime type of the embedded or inline image
+   * @access private
+   * @return mime type of ext
+   */
+  function _mime_types($ext = '') {
+    $mimes = array(
+      'hqx'  =>  'application/mac-binhex40',
+      'cpt'   =>  'application/mac-compactpro',
+      'doc'   =>  'application/msword',
+      'bin'   =>  'application/macbinary',
+      'dms'   =>  'application/octet-stream',
+      'lha'   =>  'application/octet-stream',
+      'lzh'   =>  'application/octet-stream',
+      'exe'   =>  'application/octet-stream',
+      'class' =>  'application/octet-stream',
+      'psd'   =>  'application/octet-stream',
+      'so'    =>  'application/octet-stream',
+      'sea'   =>  'application/octet-stream',
+      'dll'   =>  'application/octet-stream',
+      'oda'   =>  'application/oda',
+      'pdf'   =>  'application/pdf',
+      'ai'    =>  'application/postscript',
+      'eps'   =>  'application/postscript',
+      'ps'    =>  'application/postscript',
+      'smi'   =>  'application/smil',
+      'smil'  =>  'application/smil',
+      'mif'   =>  'application/vnd.mif',
+      'xls'   =>  'application/vnd.ms-excel',
+      'ppt'   =>  'application/vnd.ms-powerpoint',
+      'wbxml' =>  'application/vnd.wap.wbxml',
+      'wmlc'  =>  'application/vnd.wap.wmlc',
+      'dcr'   =>  'application/x-director',
+      'dir'   =>  'application/x-director',
+      'dxr'   =>  'application/x-director',
+      'dvi'   =>  'application/x-dvi',
+      'gtar'  =>  'application/x-gtar',
+      'php'   =>  'application/x-httpd-php',
+      'php4'  =>  'application/x-httpd-php',
+      'php3'  =>  'application/x-httpd-php',
+      'phtml' =>  'application/x-httpd-php',
+      'phps'  =>  'application/x-httpd-php-source',
+      'js'    =>  'application/x-javascript',
+      'swf'   =>  'application/x-shockwave-flash',
+      'sit'   =>  'application/x-stuffit',
+      'tar'   =>  'application/x-tar',
+      'tgz'   =>  'application/x-tar',
+      'xhtml' =>  'application/xhtml+xml',
+      'xht'   =>  'application/xhtml+xml',
+      'zip'   =>  'application/zip',
+      'mid'   =>  'audio/midi',
+      'midi'  =>  'audio/midi',
+      'mpga'  =>  'audio/mpeg',
+      'mp2'   =>  'audio/mpeg',
+      'mp3'   =>  'audio/mpeg',
+      'aif'   =>  'audio/x-aiff',
+      'aiff'  =>  'audio/x-aiff',
+      'aifc'  =>  'audio/x-aiff',
+      'ram'   =>  'audio/x-pn-realaudio',
+      'rm'    =>  'audio/x-pn-realaudio',
+      'rpm'   =>  'audio/x-pn-realaudio-plugin',
+      'ra'    =>  'audio/x-realaudio',
+      'rv'    =>  'video/vnd.rn-realvideo',
+      'wav'   =>  'audio/x-wav',
+      'bmp'   =>  'image/bmp',
+      'gif'   =>  'image/gif',
+      'jpeg'  =>  'image/jpeg',
+      'jpg'   =>  'image/jpeg',
+      'jpe'   =>  'image/jpeg',
+      'png'   =>  'image/png',
+      'tiff'  =>  'image/tiff',
+      'tif'   =>  'image/tiff',
+      'css'   =>  'text/css',
+      'html'  =>  'text/html',
+      'htm'   =>  'text/html',
+      'shtml' =>  'text/html',
+      'txt'   =>  'text/plain',
+      'text'  =>  'text/plain',
+      'log'   =>  'text/plain',
+      'rtx'   =>  'text/richtext',
+      'rtf'   =>  'text/rtf',
+      'xml'   =>  'text/xml',
+      'xsl'   =>  'text/xml',
+      'mpeg'  =>  'video/mpeg',
+      'mpg'   =>  'video/mpeg',
+      'mpe'   =>  'video/mpeg',
+      'qt'    =>  'video/quicktime',
+      'mov'   =>  'video/quicktime',
+      'avi'   =>  'video/x-msvideo',
+      'movie' =>  'video/x-sgi-movie',
+      'doc'   =>  'application/msword',
+      'word'  =>  'application/msword',
+      'xl'    =>  'application/excel',
+      'eml'   =>  'message/rfc822'
+    );
+    return ( ! isset($mimes[strtolower($ext)])) ? 'application/x-unknown-content-type' : $mimes[strtolower($ext)];
+  }
+
+  /**
+   * Set (or reset) Class Objects (variables)
+   *
+   * Usage Example:
+   * $page->set('X-Priority', '3');
+   *
+   * @access public
+   * @param string $name Parameter Name
+   * @param mixed $value Parameter Value
+   * NOTE: will not work with arrays, there are no arrays to set/reset
+   */
+  function set ( $name, $value = '' ) {
+    if ( isset($this->$name) ) {
+      $this->$name = $value;
+    } else {
+      $this->SetError('Cannot set or reset variable ' . $name);
+      return false;
+    }
+  }
+
+  /**
+   * Read a file from a supplied filename and return it.
+   *
+   * @access public
+   * @param string $filename Parameter File Name
+   */
+  function getFile($filename) {
+    $return = '';
+    if ($fp = fopen($filename, 'rb')) {
+      while (!feof($fp)) {
+        $return .= fread($fp, 1024);
+      }
+      fclose($fp);
+      return $return;
+    } else {
+      return false;
+    }
+  }
+
+  /**
+   * Strips newlines to prevent header injection.
+   * @access private
+   * @param string $str String
+   * @return string
+   */
+  function SecureHeader($str) {
+    $str = trim($str);
+    $str = str_replace("\r", "", $str);
+    $str = str_replace("\n", "", $str);
+    return $str;
+  }
+
+}
+
+?>