· 5 years ago · Feb 08, 2020, 02:56 AM
1//ob_start();
2set_include_path( get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/lib');
3set_include_path( get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/lib/Zend');
4error_reporting(E_ERROR);
5ini_set("max_execution_time",0);
6session_save_path(dirname(__FILE__));
7include_once 'SMTPMailer.php';
8include_once 'email_validation.php';
9
10$validator=new email_validation_class();
11
12 if(!function_exists("GetMXRR"))
13 {
14 include("getmxrr.php");
15 $_NAMESERVERS=array('8.8.8.8','8.8.4.4','4.2.2.1','4.2.2.2');
16
17 }
18 $validator->timeout=10;
19
20 $validator->data_timeout=0;
21
22 $validator->localuser="smtp-tester";
23
24 $validator->localhost="gsuite.tools";
25
26 $validator->debug = 1;
27 $validator->html_debug = 1;
28
29/*
30 * Read unsub kist
31 */
32$totalUnsubscribers = 0;
33$unsubscribersArray = array ();
34$fileHandler = fopen("storage/unsubdeatils.csv","r");
35if ($fileHandler) {
36 while (($data = fgetcsv($fileHandler, 1000, ",")) !== FALSE) {
37 $totalUnsubscribers++;
38 $data[0] = nl2br(trim($data[0]));
39 array_push($unsubscribersArray,$data[0]);
40 }
41 fclose($fileHandler);
42}
43//echo "<pre>";print_r($unsubscribersArray);exit;
44ini_set('session.gc_probability', 1);
45session_start();
46if (!isset($_SESSION['userinfo'])) {
47 header("Location: login.php");exit;
48}
49if (isset($_GET['action'])) {
50 if ($_GET['action'] == 'logout') {
51 unset($_SESSION['userinfo']);
52 header("Location: login.php");exit;
53 }
54}
55# **********
56# ** (c) 2004. All rights reserved.
57# ** You may change or alter this code so that it works on your server.
58# ** You do not have rights to resell this script unless you purchased rights.
59# **********
60# ** This delay can be set to any
61# ** whole number of seconds.
62# **********
63$send_button = "Send Message";
64$checked1 = "";
65$checked2 ="";
66$tot_emails = 0;
67$max_emails = '';
68
69$thetags = '<option value="%Email%">%Email%</option>'."\n";
70/*if (isset($_SESSION['thetags'])) {
71 $tag_array = explode(',',$_SESSION['thetags']);
72 foreach ($tag_array as $key => $value){
73 $thetags .= '<option value="%'.$value.'%">%'.$value.'%</option>'."\n";
74 }
75} */
76$term = isset($_POST['term'])?trim($_POST['term']):",";
77$tot_emails = isset($_POST['tot_emails'])?trim($_POST['tot_emails']):"0";
78
79
80
81if (isset($_POST['loadfile'])) {
82 $emaillist='';
83// echo "<pre>";print_r($_POST);exit;
84 if (($_FILES['addressfile']['error'])== 0){
85 //$content = fread(fopen($addressfile,"r"),filesize($addressfile));
86 //$addresses = split("[[:space:]]+", trim($content));
87 //$emaillist = join("\n", $addresses) . "\n";
88 //echo "<pre>";print_r($_POST);exit;
89 $lines = file2($_FILES['addressfile']['tmp_name']);
90
91 $titles_radiogroup = @$_POST['titles_radiogroup'] == 1 ? 1: 0;
92 if ($titles_radiogroup == 1) {
93 $checked1 = "checked";
94 $checked2 = "";
95 //extract the titles
96 $titles = $lines[0];
97 array_shift($lines);
98 $emaillist = join("\n", $lines);
99 $tot_emails = count($lines);
100 unset($_SESSION['thetags']);
101 $_SESSION['thetags'] = $_POST['titles'] = $titles;
102 $tag_array = explode(',',$titles);
103 foreach ($tag_array as $key => $value){
104 if ($value != 'Email'){
105 $thetags .= '<option value="%'.$value.'%">%'.$value.'%</option>'."\n";
106 }
107 }
108 }else{
109 $checked1 = "";
110 $checked2 = "checked";
111 $titles="";
112 $emaillist = join("\n", $lines);
113 // print $emaillist;exit;
114 $tot_emails = count($lines);
115 $thetags = '<option value="%Email%">%Email%</option>'."\n";
116 }
117 $enc_check = "";
118 if (@$_POST['enc']) {
119 $enc_check = "checked";
120 }
121 }
122}
123$chkContentTypePlain = "checked='checked'";
124$chkContentTypeHtml = "";
125if (isset($_POST['contenttype'])) {
126 if(@$_POST['contenttype'] == 'plain') {
127 $chkContentTypePlain = "checked='checked'";
128 $chkContentTypeHtml = "";
129 } else {
130 $chkContentTypePlain = "";
131 $chkContentTypeHtml = "checked='checked'";
132 }
133}
134
135if (isset($_POST['submit'])){
136 #Open the file attachment if any, and base64_encode it for email transport
137 /*If ($file_name){
138 @copy($file, "./$file_name") or die("The file you are trying to upload couldn't be copied to the server, make sure the folder where this script is located has it's permissions set correctly.");
139 $content = fread(fopen($file,"r"),filesize($file));
140 $content = chunk_split(base64_encode($content));
141 $uid = strtoupper(md5(uniqid(time())));
142 $name = basename($file);
143 print '<input name="ffile" type="hidden" value="true">';
144 }*/
145
146
147 $message = urlencode($_POST['message']);
148 $message = urldecode($message);
149 $message = stripslashes($message);
150 $subject = stripslashes($_POST['subject']);
151 $emaillist = stripslashes($_POST['emaillist']);
152 $max_emails = $_POST['max_emails'];
153 $term = stripslashes($_POST['term']);
154
155 if ($max_emails > 0) {
156 if ($_POST['submit'] == "Send Message") {
157 $send_button = "Resume";
158 }else{
159 $send_button = "Send Message";
160 }
161 }else{
162 $send_button = "Send Message";
163 }
164 $enc_check = "";
165 if (@$_POST['enc']) {
166 $enc_check = "checked";
167 }
168 $titles_radiogroup = @$_POST['titles_radiogroup'] == 1 ? 1: 0;
169 if ($titles_radiogroup == 1) {
170 $checked1 = "checked";
171 $checked2 = "";
172 }else{
173 $checked1 = "";
174 $checked2 = "checked";
175 }
176
177}else{
178 $send_button = "Send Message";
179}
180function file2($filename) {
181 $fp = fopen($filename, "r");
182 $buffer = fread($fp, filesize($filename));
183 $_SESSION['emaillist'] = trim($buffer);
184 fclose($fp);
185 //$lines = preg_split("/\r?\n|\r|/", trim($buffer));
186 $lines = preg_split("/\r?\n|\r/", trim($buffer));
187 // echo "<pre>";print_r($lines);
188 return $lines;
189}
190
191?>
192<html>
193<script language="JavaScript">
194<!--
195function clearAll(){
196 var f1 = document.forms[0];
197 f1.realname.value="";
198 f1.from.value="";
199 f1.replyto.value="";
200 f1.file.value="";
201 f1.subject.value="";
202 f1.message.value="";
203}
204function clearList(){
205 var f1 = document.forms[0];
206 f1.emaillist.value="";
207 f1.titles.value="";
208 f1.tot_emails.value="";
209}
210function checkvalue(){
211 var f1 = document.forms[0];
212 if (f1.max_emails.value != ""){
213 // alert(f1.max_emails.value);
214 mxe = parseFloat(f1.max_emails.value);
215 if (isNaN(mxe)){
216 wm = "The maximum number of emails is an invalid entry.";
217 alert(wm);
218 return false;
219 }else{
220 return true;
221 }
222 }
223}
224function add_tag(){
225 var f1 = document.forms[0];
226 f1.message.value = f1.message.value + f1.tags.options[f1.tags.selectedIndex].value;
227}
228
229function scrollWindow() {
230 window.scrollBy(0, document.body.scrollHeight);
231}
232function initScroll() {
233 setInterval("scrollWindow()", 100);
234}
235//-->
236</script>
237<body>
238<p align="right"><a href="index.php?action=logout">Logout</a> | <a href="" target="_blank">Help</a>
239<form name="form1" method="post" action="" enctype="multipart/form-data" style="margin:0px" onsubmit="return (checkvalue())">
240<table width="85%" border="0" cellspacing="0" cellpadding="3" align="center">
241 <tr>
242 <td height="25" colspan="2" valign="top">
243 <div align="center" style="margin-bottom: 20px;"><font size="4" face="Verdana, Arial, Helvetica, sans-serif"><strong><a href="" target="_blank">BLACK URIE</a>
244 </strong></font></div>
245 </td>
246 </tr>
247 <tr align="center">
248 <td width="40%" height="575" valign="top">
249 <table width="300" height="569" border="0" align="center" cellpadding="1" cellspacing="0">
250 <tr>
251 <td width="520" height="23" bgcolor="black"> <div align="center"><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif"><strong>Step
252 1: Load Your Mailing List</strong></font></div></td>
253 </tr>
254 <tr>
255 <td height="546" valign="top" bgcolor="black">
256 <table width="100%" height="522" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
257 <tr>
258 <td height="34" colspan="2"> <div align="center"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
259 <input type=file name=addressfile>
260 </font></div></td>
261 </tr>
262 <tr>
263 <td width="54%" height="32"> <div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Fields
264 terminated by:</font></div></td>
265 <td width="46%"><input name="term" type="text" id="term" value="<?php print $term; ?>" size="10"></td>
266 </tr>
267 <tr>
268 <td height="26" colspan="2"> <div align="left"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
269 <input name="enc" type="checkbox" value="checkbox" <?php print isset($_POST['enc'])?'checked':''; ?>>
270 Enclosed Fields</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
271 </font></div></td>
272 </tr>
273 <tr>
274 <td height="26" colspan="2"> <p align="left">
275 <label>
276 <input name="titles_radiogroup" type="radio" value="1" <?php print $checked1; ?>>
277 <font size="2" face="Verdana, Arial, Helvetica, sans-serif">With
278 Titles</font></label>
279 <br>
280 <label>
281 <input type="radio" name="titles_radiogroup" value="0" <?php print $checked2; ?>>
282 <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Without
283 Titles</font></label>
284 <br>
285 </p></td>
286 </tr>
287 <tr>
288 <td height="34" colspan="2"><div align="center"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
289 <input name="loadfile" type="submit" id="loadfile" value="Load Addresses From File">
290 </font></div></td>
291 </tr>
292 <tr>
293 <td height="32" colspan="2"> <div align="center"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
294 </font> <font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Titles:
295 <input name="titles" type="text" id="titles" value="<?php print @$_POST['titles']; ?>" size="30">
296 </font></div></td>
297 </tr>
298 <tr>
299 <td height="272" colspan="2" valign="top"> <div align="center"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
300 <textarea name="emaillist" cols="30" rows="15" wrap="OFF"><?php print @$emaillist; ?></textarea>
301 </font></div></td>
302 </tr>
303 <tr>
304 <td height="32" valign="top"> <div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Total
305 Emails:</font></div></td>
306 <td height="32" valign="top"> <input name="tot_emails" type="text" id="tot_emails" value="<?php print $tot_emails; ?>" size="10"></td>
307 </tr>
308 <tr>
309 <td height="34" colspan="2" valign="top"> <div align="center"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
310 <input type="button" name="Button" value="Clear List" onClick="clearList()">
311 </font></div></td>
312 </tr>
313 </table></td>
314 </tr>
315 </table></td>
316 <td width="60%" valign="top">
317 <table width="500" height="449" border="0" align="center" cellpadding="1" cellspacing="0">
318 <tr>
319 <td height="22" bgcolor="black"> <div align="center"><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif"><strong>Step
320 2: Deliver Your Emails</strong></font></div></td>
321 </tr>
322 <tr>
323 <td height="427" valign="top" bgcolor="black">
324 <table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
325 <tr>
326 <td width="20%">
327 <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Your
328 Name:</font></div>
329 </td>
330 <td width="80%"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
331 <input type="text" name="realname" value="<?php print @$_POST['realname']; ?>" size="30">
332 </font></td>
333 </tr>
334 <tr>
335 <td>
336 <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Your
337 Email:</font></div>
338 </td>
339 <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
340 <input type="text" name="from" value="<?php print @$_POST['from']; ?>" size="30">
341 </font></td>
342 </tr>
343 <tr>
344 <td>
345 <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Reply-To:</font></div>
346 </td>
347 <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
348 <input type="text" name="replyto" value="<?php print @$_POST['replyto']; ?>" size="30">
349 </font></td>
350 </tr>
351 <tr>
352 <td>
353 <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Subject:</font></div>
354 </td>
355 <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
356 <input type="text" name="subject" value="<?php print @$_POST['subject']; ?>" size="58">
357 </font></td>
358 </tr>
359 <tr>
360 <td>
361 <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Delay:</font></div>
362 </td>
363 <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
364 <input name="delaySecs" type="text" value="<?php echo @$_POST['delaySecs'];?>" size="10" >
365 Minimum 1 seconds</font></td>
366 </tr>
367 <tr>
368 <td>
369 <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Max
370 Emails:</font></div>
371 </td>
372 <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
373 <input name="max_emails" type="text" value="<?php print @$max_emails; ?>" size="10">
374 Leave blank to send to all emails</font></td>
375 </tr>
376 <tr>
377 <td>
378 <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Titles:</font></div>
379 </td>
380 <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
381 <select name="tags" id="tags" onChange="add_tag()">
382 <?php print @$thetags; ?>
383 </select>
384 </font></td>
385 </tr>
386 <tr>
387 <td colspan="2">
388 <div align="center"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
389 <textarea name="message" cols="60" rows="10" wrap="OFF"><?php print stripslashes(@$_POST['message']); ?></textarea>
390 <br>
391 <input type="radio" name="contenttype" value="plain" <?php echo $chkContentTypePlain;?> >
392 Plain
393 <input type="radio" name="contenttype" value="html" <?php echo $chkContentTypeHtml;?> >
394 HTML </font></div>
395 </td>
396 </tr>
397 <!-- attachment start -->
398 <tr>
399 <td>
400 <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Attachment
401 </font></div>
402 </td>
403 <td><input type="file" name="attachment"/></td>
404 </tr>
405 <!-- attachment ends -->
406 <tr>
407 <td colspan="2">
408 <?php $chkUndubLink= isset($_POST['chk_unsublink']) ? "checked='checked'" : ""; ?>
409 <input type="checkbox" name="chk_unsublink" value="1" <?php echo $chkUndubLink; ?>/>
410 <font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
411 Do you want to include the UNSUBSCRIBE LINK ?</font><br/>Unsubscribers: <a href="storage/unsubdeatils.csv" target="_blank"><?php echo $totalUnsubscribers;?> </a>so far </td>
412 </tr>
413 <!-- Email Exists UI Starts -->
414 <tr>
415 <td colspan="2">
416 <?php $chkEmailExists= isset($_POST['chk_emailexists']) ? "checked='checked'" : ""; ?>
417 <input type="checkbox" name="chk_emailexists" value="1" <?php echo $chkEmailExists; ?>/>
418 <font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
419 Do you want to check the REAL EXISTENCE of an email address before actually sending
420 an email to it? This will thus avoid 99% of bounces</font> </td>
421 </tr>
422 <?php $_POST['localuser'] = isset($_POST['localuser'])?$_POST['localuser'] : "smtp-tester";?>
423 <tr>
424 <td> <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">localuser :</font> </div></td>
425 <td> <input type='text' name='localuser' size='25' value="<?php echo $_POST['localuser']?>" /> </td>
426
427 </tr>
428 <tr>
429 <td colspan="2">
430
431 <p style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size: 10px;">
432 (Type any local email account present on this domain on which
433 this DM software is installed. For example if your
434 domain is underpricedhost.com and if support@underpricedhost.com is the
435 email account then type "support" as a localuser.
436 support@underpricedhost.com should be a real existing email account.)
437 </p> </td>
438 </tr>
439 <?php $_POST['localhost'] = isset($_POST['localhost'])?$_POST['localhost'] : "gsuite.tools";?>
440 <tr>
441 <td> <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">localhost :</font><br/>
442 </div></td>
443 <td> <input type='text' name='localhost' size='25' value="<?php echo $_POST['localhost']?>" /> </td>
444
445 </tr>
446 <tr>
447 <td colspan="2">
448
449 <p style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size: 10px;">
450 (Type the exact domain name on which
451 this DM software is installed. For example if underpricedhost.com
452 is the domain on which you have installed this DM software then
453 type "underpricedhost.com" as a localhost.)
454 </p> </td>
455 </tr>
456 <!-- Email Exists UI Ends -->
457 <tr>
458 <?php
459 $chkSmtp = isset($_POST['chk_smtp']) ? "checked='checked'" : "";
460
461 ?>
462 <td colspan="2"> <input type="checkbox" name="chk_smtp" value="external" <?php echo $chkSmtp;?>/>
463 <font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> Do you want to use External SMTP Server </font></td>
464 </tr>
465 <tr>
466 <td> <div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">SMTP Host :</font> </div></td>
467 <td> <input type='text' name='smtp_host' size='25' value="<?php echo $_POST['smtp_host']?>" /> </td>
468
469 </tr>
470 <?php
471 $smtpPort = isset($_POST['smtp_port']) ? $_POST['smtp_port'] : 25;
472 ?>
473 <tr>
474 <td><div align="right">
475 <font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
476 SMTP Port :
477 </font></div> </td><td><input type="text" name='smtp_port' size='4' maxlength="4" value="<?php echo $smtpPort;?>"/> </td>
478 </tr>
479 <tr>
480 <td><div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> Login ID :</font> </div> </td><td><input type="text" name='smtp_username' size='25' maxlength="50" value="<?php echo $_POST['smtp_username']?>"/> </td>
481 </tr>
482 <tr>
483 <td><div align="right"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> Password : </font></div> </td><td><input type="password" name='smtp_password' size='25' maxlength="50" value="<?php echo $_POST['smtp_password']?>"/> </td>
484 </tr>
485 <tr>
486 <?php
487 $chkSmtpSecure = isset($_POST['chk_smtp_secure']) ? "checked='checked'" : "";
488
489 ?>
490 <td colspan="2"> <input type="checkbox" name="chk_smtp_secure" value="1" <?php echo $chkSmtpSecure;?>/><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> Enable secure connection</font></td>
491 </tr>
492 <tr>
493 <td height="55" colspan="2">
494 <table width="100%" border="0" cellspacing="0" cellpadding="1">
495 <tr>
496 <td width="51%" height="31">
497 <div align="center"> </div>
498 <div align="center"> </div>
499 <div align="center"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
500 <input type="button" name="Button" value="Clear All" onClick="clearAll()">
501 </font></div>
502 </td>
503 <td width="49%">
504 <div align="center"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
505 <input name="submit" type="submit" id="submit" value="<?php print @$send_button ?>">
506 </font></div>
507 </td>
508 </tr>
509 </table>
510 </td>
511 </tr>
512 </table>
513 </td>
514 </tr>
515 </table></td>
516 </tr>
517</table>
518</form>
519</body>
520</html>
521<div style="margin-left:200px;">
522 <?php
523if (isset($_POST['submit'])){
524 /*
525 * Attachment
526 */
527 $fileatt = $_FILES['attachment']['tmp_name'];
528 $fileatt_type = $_FILES['attachment']['type'];
529 $fileatt_name = $_FILES['attachment']['name'];
530
531
532 $validator->localuser= trim($_POST['localuser']);
533
534 $validator->localhost= trim($_POST['localhost']);
535
536 //echo "<pre>";var_dump($term);
537 // echo "<pre>";print_r($_POST);exit;
538 $titles_radiogroup = @$_POST['titles_radiogroup'] == 1 ? 1: 0;
539 $submit = $_POST['submit'];
540 //obtain flags
541 $start_num = 0;
542 $pause=false;$send=false;
543 if (strpos($submit, 'Resume')!==false) {$pause=true;}
544 else if (strpos($submit, 'Send')!==false) {$send=true;}
545
546
547 if ($pause) {
548 //display sent emails
549 foreach ($_POST as $key => $value){
550
551 if (strpos($key, 'sentemail')!==false) {
552 $em = explode('_',$key);
553 $last_id = $em[1];
554 $email_num = $last_id+1;
555 print $email_num.' Sending mail to <font color="#FF00FF">'.$value.'</font><font size="7" color="#0000FF"> ... Successfull!</font><br>';
556 print '<input name="'.$key.'" type="hidden" value="'.$value.'">';
557 }
558 }
559
560 if ($submit=='Resume') {
561 print "Process has been resumed.<br>";
562 $send=true;
563 $start_num = $last_id+1;
564 }else{
565 exit;
566 }
567 }
568
569 if ($send) {
570 $from = $_POST['from'];
571 $subject = $_POST['subject'];
572 $message = $_POST['message'];
573 $emaillist = $_POST['emaillist'];
574 $realname = $_POST['realname'];
575
576 $message = urlencode($_POST['message']);
577 $message = urldecode($message);
578 $message = stripslashes($message);
579 $subject = stripslashes($_POST['subject']);
580 $emaillist = stripslashes($_POST['emaillist']);
581 $max_emails = $_POST['max_emails'];
582 $term = stripslashes($_POST['term']);
583
584 if (!$from || !$subject || !$message || !$emaillist){
585 print "Please complete all fields before sending your message.";
586 exit;
587 }
588 $delaySecs = (int) $_POST['delaySecs'];
589 if($delaySecs <= -1) {
590 print "Delay seconds must me greater than 0";exit;
591 }
592 //obtain email data
593 $emaillist=trim($emaillist);
594 $allemails = explode("\n", $emaillist);
595 //echo "<pre>";var_dump($titles_radiogroup);exit;
596 if ($titles_radiogroup == 1) {
597
598 foreach ($allemails as $key => $row){
599 if (strpos($row,$term)===false) {
600 print "The given termination delimiter was not found, make sure you entered it correctly.";
601 exit;
602 }
603 $emaildata[$key] = explode($term,$row);
604 $enc = $_POST['enc'];
605 if ($enc) {
606 foreach ($emaildata[$key] as $key2 => $value) {
607 $emaildata[$key][$key2] = substr($value,1,strlen($value)-2);
608 }
609 }
610 }
611 //determine the email index
612 $email_ind = 0;
613 $the_titles = explode(',',$_POST['titles']);
614
615 foreach ($the_titles as $key => $value) {
616 $value = strtolower($value);
617 if (strpos($value,"email")!==false) {
618 $email_ind = $key;
619 // print $email_ind;exit;
620 break;
621 }
622 }
623
624 //construct the tag titles array
625 foreach ($the_titles as $key => $value) {
626 $st = '%'.$value.'%';
627 $the_titles[$key] = $st;
628 }
629
630 }
631 $numemails = count($allemails);
632 if ($max_emails) {
633 $numemails = $max_emails;
634 }
635 if ($numemails > $tot_emails) {
636 $numemails = $tot_emails;
637 }
638
639 /**
640 * Create SMTP
641 */
642 $smtpMailer = new SMTPMailer();
643 if(isset($_POST['chk_smtp']) && $_POST['chk_smtp'] == 'external') {
644
645
646
647 if (!trim($_POST['smtp_host']) | !trim($_POST['smtp_port']) | !trim($_POST['smtp_username']) | !trim($_POST['smtp_password'])) {
648 print "Please complete SMTP info";exit;
649 }
650 $intPattern = "/([0-9]{2,4})$/";
651 if (!preg_match($intPattern,trim($_POST['smtp_port']),$matches)) {
652
653 print "Invalid SMTP Port";exit;
654 }
655
656 $smtpMailer -> setSmtpHost(trim($_POST['smtp_host']));
657 $smtpMailer -> setSmtpUsername(trim($_POST['smtp_username']));
658 $smtpMailer -> setSmtpPassword(trim($_POST['smtp_password']));
659 $smtpMailer -> setSmtpPort($_POST['smtp_port']);
660 if (isset($_POST['chk_smtp_secure'])){
661 $smtpMailer -> setIsSecure(true);
662 } else {
663 $smtpMailer -> setIsSecure(false);
664 }
665
666 $smtpMailer -> setMailType($_POST['contenttype']);
667
668 $smtpMailer -> setMailFrom($realname);
669 $smtpMailer -> setMailFromEmail($from);
670
671 $smtpMailer -> setReplayMail($_POST['replyto']);
672 try {
673 $smtpMailer -> createSMTP();
674 }catch (Zend_Exception $e) {
675 print "<br/>".$e->getMessage ();exit;
676 }
677
678
679 }
680 //process the emails
681 //echo "<pre>";print_r($emaildata);
682 for($x=$start_num; $x<$numemails; $x++){
683 print "<script type='text/javascript'>scrollWindow();</script>";
684 if ($titles_radiogroup == 1) {$to = $emaildata[$x][$email_ind];}
685 else{$to = $allemails[$x];}
686 if ($to){
687 //replace tag titles
688 $tmp_message = $message;
689 $tmp_subject = $subject;
690 //var_dump($titles_radiogroup);
691 if ($titles_radiogroup == 1) {
692 foreach ($the_titles as $key => $value){
693 }
694 }else{
695 // print $message;
696 // print ">>>".$message;
697 }
698 $email_num = $x+1;
699 $contenttype = $_POST['contenttype'];
700 $replyto = $_POST['replyto'];
701 $uid = strtoupper(md5(uniqid(time())));
702 $unsubLinkFlag = false;
703 if (count ($unsubscribersArray) > 0) {
704 if (in_array(trim($to),$unsubscribersArray)) {
705 print $email_num.' Sorry I wont send him email. '.$to.' has already unsubscribed.<br/>';
706 $unsubLinkFlag = true;
707 }else {
708 print $email_num.' Checking syntax of <font color="#FF00FF">'.$to.'</font>';
709 }
710 } else {
711 print $email_num.' Checking syntax of <font color="#FF00FF">'.$to.'</font>';
712 }
713 $pattern = "/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i";
714 if ($unsubLinkFlag === false) {
715 if(!preg_match($pattern,trim($to))) {
716 print "<font color='#FF0000'>... Invalid Email Address!</font><br>";
717 flush();
718 continue;
719 } else {
720
721 print "... Seems good!<br>";
722 }
723 }
724
725 print '<input name="sentemail_'.$x.'" type="hidden" value="'.$to.'">';
726 flush();
727 if(isset($_POST['chk_unsublink'])) {
728 $serverInfo = $_SERVER['PHP_SELF'];
729 $serverInfoArray = explode("/",$serverInfo);
730 unset($serverInfoArray[count($serverInfoArray)-1]);
731
732 $unLink = $_SERVER['HTTP_HOST'].implode("/",$serverInfoArray)."/unsubscribe.php?email=".$to;
733 if ($contenttype == 'plain') {
734 $unLink ="To Unsubscribe, please click here\n".$unLink;
735
736 }else {
737 $unLink = "To unsubscribe, please <a href='".$unLink."'>click here</a>";
738 }
739
740 $message = $message."\n\n".$unLink;
741 }
742 if ($unsubLinkFlag === false) {
743 if (isset($_POST['chk_emailexists'])) {
744 $result = $validator->ValidateEmailBox(trim($to));
745 if($result == 0){
746 foreach($result as $ress)
747 $file = fopen("./Valid/Valid.txt","w");
748 fwrite($file,$ress."\n");
749
750 print "<br><font size='5' color='#FF0000'>The Email address $to may not be valid and may be undeliverable.</font><br>";
751 flush();
752 continue;
753 }else if($result == 1){
754 print "<br><font size='5' color='#008000'>Email Address $to is valid and deliverable.</font><br>";
755 foreach($result as $res)
756 $file = fopen("./Invalid/invalid.txt","w");
757 fwrite($file,$res."\n");
758
759 }else {
760 print "<br><font size='5' style='color:#FF0000'>The Email address $to may not be valid and may be undeliverable.</font><br>";
761 foreach($result as $resss)
762 $file = fopen("./Invalid/invalid.txt","w");
763 fwrite($file,$resss."\n");
764
765
766 }
767 flush();
768 }
769
770 print " Sending mail to $to ...";
771 }
772
773 if(isset($_POST['chk_smtp']) && $_POST['chk_smtp'] == 'external') {
774 $smtpMailer->setMailSubject($subject);
775
776 if ($unsubLinkFlag === false) {
777 if ($contenttype == 'plain') {
778 $smtpMailer->setMailType('plain');
779 }else{
780 $smtpMailer->setMailType('html');
781 $message = stripslashes($message);
782 }
783 $smtpMailer->setMailBody($message);
784 $attachmentArray = array();
785 if (is_uploaded_file($fileatt)) {
786 $file = fopen($fileatt, 'rb');
787 $data = fread($file, filesize($fileatt));
788 $attachmentArray['data'] = $data;
789 $attachmentArray['type'] = $fileatt_type;
790 $attachmentArray['name'] = $fileatt_name;
791
792 }
793 if($smtpMailer->sendEmails($to,$attachmentArray) === true){
794 print '<font color="#0000FF"> ... Successfull!</font><br>';
795 }else{
796 print '<font color="#FF0000"> ... Aborted!</font><br>';
797 }
798
799
800 }
801
802 } else {
803 $smtpMailer -> setMailType($_POST['contenttype']);
804
805 $smtpMailer -> setMailFrom($realname);
806 $smtpMailer -> setMailFromEmail($from);
807
808 $smtpMailer -> setReplayMail($_POST['replyto']);
809
810 $smtpMailer->setMailSubject($subject);
811 if ($contenttype == 'plain') {
812 $smtpMailer->setMailType('plain');
813 }else{
814 $smtpMailer->setMailType('html');
815 $message = stripslashes($message);
816 }
817 $smtpMailer->setMailBody($message);
818
819 $attachmentArray = array();
820 if (is_uploaded_file($fileatt)) {
821 $file = fopen($fileatt, 'rb');
822 $data = fread($file, filesize($fileatt));
823 $attachmentArray['data'] = $data;
824 $attachmentArray['type'] = $fileatt_type;
825 $attachmentArray['name'] = $fileatt_name;
826
827 }
828 if ($unsubLinkFlag === false) {
829 if($smtpMailer->defaultMailer($to,$attachmentArray) === true){
830 print '<font size="5" color="#0000FF"> ... Successfull!</font><br>';
831 }else{
832 print '<font color="#FF0000"> ... Aborted!</font><br>';
833 }
834
835 }
836 }
837
838
839
840
841 sleep($delaySecs);
842 flush();
843 $message = $tmp_message;
844 $subject = $tmp_subject;
845 }
846 }
847 if ($numemails == $tot_emails) {
848 print "Done!<br>";
849 }else if ($start_num >= $max_emails) {
850 print "Error: you forgot to increase the maximum number of emails.<br>";
851 $submit = "Send Message";
852 }else{
853 if ($max_emails) {
854 if (@$ffile) {
855 print 'Process has been paused ... <font color="#FF0000">NOTE: You must re-attach your attached file before resuming.</font><br>';
856 }else{
857 print 'Process has been paused ... <font color="#0000FF">Enter in the new Maximum number of emails and click the Resume button.</font><br>';
858 }
859 }
860 }
861 }
862}