· 5 years ago · Feb 02, 2020, 03:38 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 $_NAMESERVERS=array('8.8.8.8','8.8.4.4','4.2.2.1','4.2.2.2');
15 include("getmxrr.php");
16 }
17 $validator->timeout=10;
18
19 $validator->data_timeout=0;
20
21 $validator->localuser="verify";
22
23 $validator->localhost="emailaddressverifier.com";
24
25 $validator->debug = 1;
26 $validator->html_debug = 1;
27
28/*
29 * Read unsub kist
30 */
31$totalUnsubscribers = 0;
32$unsubscribersArray = array ();
33$fileHandler = fopen("storage/unsubdeatils.csv","r");
34if ($fileHandler) {
35 while (($data = fgetcsv($fileHandler, 1000, ",")) !== FALSE) {
36 $totalUnsubscribers++;
37 $data[0] = nl2br(trim($data[0]));
38 array_push($unsubscribersArray,$data[0]);
39 }
40 fclose($fileHandler);
41}
42//echo "<pre>";print_r($unsubscribersArray);exit;
43ini_set('session.gc_probability', 1);
44session_start();
45if (!isset($_SESSION['userinfo'])) {
46 header("Location: login.php");exit;
47}
48if (isset($_GET['action'])) {
49 if ($_GET['action'] == 'logout') {
50 unset($_SESSION['userinfo']);
51 header("Location: login.php");exit;
52 }
53}
54# **********
55# ** (c) 2004. All rights reserved.
56# ** You may change or alter this code so that it works on your server.
57# ** You do not have rights to resell this script unless you purchased rights.
58# **********
59# ** This delay can be set to any
60# ** whole number of seconds.
61# **********
62$send_button = "Send Message";
63$checked1 = "";
64$checked2 ="";
65$tot_emails = 0;
66$max_emails = '';
67
68$thetags = '<option value="%Email%">%Email%</option>'."\n";
69/*if (isset($_SESSION['thetags'])) {
70 $tag_array = explode(',',$_SESSION['thetags']);
71 foreach ($tag_array as $key => $value){
72 $thetags .= '<option value="%'.$value.'%">%'.$value.'%</option>'."\n";
73 }
74} */
75$term = isset($_POST['term'])?trim($_POST['term']):",";
76$tot_emails = isset($_POST['tot_emails'])?trim($_POST['tot_emails']):"0";
77
78
79
80if (isset($_POST['loadfile'])) {
81 $emaillist='';
82// echo "<pre>";print_r($_POST);exit;
83 if (($_FILES['addressfile']['error'])== 0){
84 //$content = fread(fopen($addressfile,"r"),filesize($addressfile));
85 //$addresses = split("[[:space:]]+", trim($content));
86 //$emaillist = join("\n", $addresses) . "\n";
87 //echo "<pre>";print_r($_POST);exit;
88 $lines = file2($_FILES['addressfile']['tmp_name']);
89
90 $titles_radiogroup = @$_POST['titles_radiogroup'] == 1 ? 1: 0;
91 if ($titles_radiogroup == 1) {
92 $checked1 = "checked";
93 $checked2 = "";
94 //extract the titles
95 $titles = $lines[0];
96 array_shift($lines);
97 $emaillist = join("\n", $lines);
98 $tot_emails = count($lines);
99 unset($_SESSION['thetags']);
100 $_SESSION['thetags'] = $_POST['titles'] = $titles;
101 $tag_array = explode(',',$titles);
102 foreach ($tag_array as $key => $value){
103 if ($value != 'Email'){
104 $thetags .= '<option value="%'.$value.'%">%'.$value.'%</option>'."\n";
105 }
106 }
107 }else{
108 $checked1 = "";
109 $checked2 = "checked";
110 $titles="";
111 $emaillist = join("\n", $lines);
112 // print $emaillist;exit;
113 $tot_emails = count($lines);
114 $thetags = '<option value="%Email%">%Email%</option>'."\n";
115 }
116 $enc_check = "";
117 if (@$_POST['enc']) {
118 $enc_check = "checked";
119 }
120 }
121}
122$chkContentTypePlain = "checked='checked'";
123$chkContentTypeHtml = "";
124if (isset($_POST['contenttype'])) {
125 if(@$_POST['contenttype'] == 'plain') {
126 $chkContentTypePlain = "checked='checked'";
127 $chkContentTypeHtml = "";
128 } else {
129 $chkContentTypePlain = "";
130 $chkContentTypeHtml = "checked='checked'";
131 }
132}
133
134if (isset($_POST['submit'])){
135 #Open the file attachment if any, and base64_encode it for email transport
136 /*If ($file_name){
137 @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.");
138 $content = fread(fopen($file,"r"),filesize($file));
139 $content = chunk_split(base64_encode($content));
140 $uid = strtoupper(md5(uniqid(time())));
141 $name = basename($file);
142 print '<input name="ffile" type="hidden" value="true">';
143 }*/
144
145
146 $message = urlencode($_POST['message']);
147 $message = preg_replace("%5C%22", "%22", $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="http://www.dangerousmailer.com/help" 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="http://dangerousmailer.com" target="_blank">DANGEROUS MAILER</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="#4AA5FF"> <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="#4AA5FF">
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="<? 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="#4AA5FF"> <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="#4AA5FF">
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="<? 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="<? 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="<? 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="<? 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="<? 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"><? 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'] : "verify";?>
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'] : "emailaddressverifier.com";?>
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 = preg_replace("%5C%22", "%22", $message);
578 $message = urldecode($message);
579 $message = stripslashes($message);
580 $subject = stripslashes($_POST['subject']);
581 $emaillist = stripslashes($_POST['emaillist']);
582 $max_emails = $_POST['max_emails'];
583 $term = stripslashes($_POST['term']);
584
585 if (!$from || !$subject || !$message || !$emaillist){
586 print "Please complete all fields before sending your message.";
587 exit;
588 }
589 $delaySecs = (int) $_POST['delaySecs'];
590 if($delaySecs <= -1) {
591 print "Delay seconds must me greater than 0";exit;
592 }
593 //obtain email data
594 $emaillist=trim($emaillist);
595 $allemails = split("\n", $emaillist);
596 //echo "<pre>";var_dump($titles_radiogroup);exit;
597 if ($titles_radiogroup == 1) {
598
599 foreach ($allemails as $key => $row){
600 if (strpos($row,$term)===false) {
601 print "The given termination delimiter was not found, make sure you entered it correctly.";
602 exit;
603 }
604 $emaildata[$key] = explode($term,$row);
605 $enc = $_POST['enc'];
606 if ($enc) {
607 foreach ($emaildata[$key] as $key2 => $value) {
608 $emaildata[$key][$key2] = substr($value,1,strlen($value)-2);
609 }
610 }
611 }
612 //determine the email index
613 $email_ind = 0;
614 $the_titles = explode(',',$_POST['titles']);
615
616 foreach ($the_titles as $key => $value) {
617 $value = strtolower($value);
618 if (strpos($value,"email")!==false) {
619 $email_ind = $key;
620 // print $email_ind;exit;
621 break;
622 }
623 }
624
625 //construct the tag titles array
626 foreach ($the_titles as $key => $value) {
627 $st = '%'.$value.'%';
628 $the_titles[$key] = $st;
629 }
630
631 }
632 $numemails = count($allemails);
633 if ($max_emails) {
634 $numemails = $max_emails;
635 }
636 if ($numemails > $tot_emails) {
637 $numemails = $tot_emails;
638 }
639
640 /**
641 * Create SMTP
642 */
643 $smtpMailer = new SMTPMailer();
644 if(isset($_POST['chk_smtp']) && $_POST['chk_smtp'] == 'external') {
645
646
647
648 if (!trim($_POST['smtp_host']) | !trim($_POST['smtp_port']) | !trim($_POST['smtp_username']) | !trim($_POST['smtp_password'])) {
649 print "Please complete SMTP info";exit;
650 }
651 $intPattern = "/([0-9]{2,4})$/";
652 if (!preg_match($intPattern,trim($_POST['smtp_port']),$matches)) {
653
654 print "Invalid SMTP Port";exit;
655 }
656
657 $smtpMailer -> setSmtpHost(trim($_POST['smtp_host']));
658 $smtpMailer -> setSmtpUsername(trim($_POST['smtp_username']));
659 $smtpMailer -> setSmtpPassword(trim($_POST['smtp_password']));
660 $smtpMailer -> setSmtpPort($_POST['smtp_port']);
661 if (isset($_POST['chk_smtp_secure'])){
662 $smtpMailer -> setIsSecure(true);
663 } else {
664 $smtpMailer -> setIsSecure(false);
665 }
666
667 $smtpMailer -> setMailType($_POST['contenttype']);
668
669 $smtpMailer -> setMailFrom($realname);
670 $smtpMailer -> setMailFromEmail($from);
671
672 $smtpMailer -> setReplayMail($_POST['replyto']);
673 try {
674 $smtpMailer -> createSMTP();
675 }catch (Zend_Exception $e) {
676 print "<br/>".$e->getMessage ();exit;
677 }
678
679
680 }
681 //process the emails
682 //echo "<pre>";print_r($emaildata);
683 for($x=$start_num; $x<$numemails; $x++){
684 print "<script type='text/javascript'>scrollWindow();</script>";
685 if ($titles_radiogroup == 1) {$to = $emaildata[$x][$email_ind];}
686 else{$to = $allemails[$x];}
687 if ($to){
688 $to = preg_replace(" ", "", $to);
689 //replace tag titles
690 $tmp_message = $message;
691 $tmp_subject = $subject;
692 //var_dump($titles_radiogroup);
693 if ($titles_radiogroup == 1) {
694 foreach ($the_titles as $key => $value){
695 $message = preg_replace($value, $emaildata[$x][$key], $message);
696 $subject = preg_replace($value, $emaildata[$x][$key], $subject);
697 }
698 }else{
699 // print $message;
700 $message = preg_replace("%Email%", $to, $message);
701 // print ">>>".$message;
702 $subject = preg_replace("%Email%", $to, $subject);
703 }
704 $email_num = $x+1;
705 $contenttype = $_POST['contenttype'];
706 $replyto = $_POST['replyto'];
707 $uid = strtoupper(md5(uniqid(time())));
708 $unsubLinkFlag = false;
709 if (count ($unsubscribersArray) > 0) {
710 if (in_array(trim($to),$unsubscribersArray)) {
711 print $email_num.' Sorry I wont send him email. '.$to.' has already unsubscribed.<br/>';
712 $unsubLinkFlag = true;
713 }else {
714 print $email_num.' Checking syntax of <font color="#FF00FF">'.$to.'</font>';
715 }
716 } else {
717 print $email_num.' Checking syntax of <font color="#FF00FF">'.$to.'</font>';
718 }
719 $pattern = "/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i";
720 if ($unsubLinkFlag === false) {
721 if(!preg_match($pattern,trim($to))) {
722 print "<font color='#FF0000'>... Invalid Email Address!</font><br>";
723 flush();
724 continue;
725 } else {
726
727 print "... Seems good!<br>";
728 }
729 }
730
731 print '<input name="sentemail_'.$x.'" type="hidden" value="'.$to.'">';
732 flush();
733 if(isset($_POST['chk_unsublink'])) {
734 $serverInfo = $_SERVER['PHP_SELF'];
735 $serverInfoArray = explode("/",$serverInfo);
736 unset($serverInfoArray[count($serverInfoArray)-1]);
737
738 $unLink = $_SERVER['HTTP_HOST'].implode("/",$serverInfoArray)."/unsubscribe.php?email=".$to;
739 if ($contenttype == 'plain') {
740 $unLink ="To Unsubscribe, please click here\n".$unLink;
741
742 }else {
743 $unLink = "To unsubscribe, please <a href='".$unLink."'>click here</a>";
744 }
745
746 $message = $message."\n\n".$unLink;
747 }
748 if ($unsubLinkFlag === false) {
749 if (isset($_POST['chk_emailexists'])) {
750 $result = $validator->ValidateEmailBox(trim($to));
751 if($result == 0){
752 print "<br><font size='5' color='#FF0000'>The Email address $to may not be valid and may be undeliverable.</font><br>";
753 flush();
754 continue;
755 }else if($result == 1){
756
757 print "<br><font size='5' color='#008000'>Email Address $to is valid and deliverable.</font><br>";
758 }else {
759 print "<br><font size='5' style='color:#FF0000'>The Email address $to may not be valid and may be undeliverable.</font><br>";
760 }
761 flush();
762 }
763
764 print " Sending mail to $to ...";
765 }
766
767 if(isset($_POST['chk_smtp']) && $_POST['chk_smtp'] == 'external') {
768 $smtpMailer->setMailSubject($subject);
769
770 if ($unsubLinkFlag === false) {
771 if ($contenttype == 'plain') {
772 $smtpMailer->setMailType('plain');
773 }else{
774 $smtpMailer->setMailType('html');
775 $message = stripslashes($message);
776 }
777 $smtpMailer->setMailBody($message);
778 $attachmentArray = array();
779 if (is_uploaded_file($fileatt)) {
780 $file = fopen($fileatt, 'rb');
781 $data = fread($file, filesize($fileatt));
782 $attachmentArray['data'] = $data;
783 $attachmentArray['type'] = $fileatt_type;
784 $attachmentArray['name'] = $fileatt_name;
785
786 }
787 if($smtpMailer->sendEmails($to,$attachmentArray) === true){
788 print '<font color="#0000FF"> ... Successfull!</font><br>';
789 }else{
790 print '<font color="#FF0000"> ... Aborted!</font><br>';
791 }
792
793
794 }
795
796 } else {
797 $smtpMailer -> setMailType($_POST['contenttype']);
798
799 $smtpMailer -> setMailFrom($realname);
800 $smtpMailer -> setMailFromEmail($from);
801
802 $smtpMailer -> setReplayMail($_POST['replyto']);
803
804 $smtpMailer->setMailSubject($subject);
805 if ($contenttype == 'plain') {
806 $smtpMailer->setMailType('plain');
807 }else{
808 $smtpMailer->setMailType('html');
809 $message = stripslashes($message);
810 }
811 $smtpMailer->setMailBody($message);
812
813 $attachmentArray = array();
814 if (is_uploaded_file($fileatt)) {
815 $file = fopen($fileatt, 'rb');
816 $data = fread($file, filesize($fileatt));
817 $attachmentArray['data'] = $data;
818 $attachmentArray['type'] = $fileatt_type;
819 $attachmentArray['name'] = $fileatt_name;
820
821 }
822 if ($unsubLinkFlag === false) {
823 if($smtpMailer->defaultMailer($to,$attachmentArray) === true){
824 print '<font size="5" color="#0000FF"> ... Successfull!</font><br>';
825 }else{
826 print '<font color="#FF0000"> ... Aborted!</font><br>';
827 }
828
829 }
830 }
831
832
833
834
835 sleep($delaySecs);
836 flush();
837 $message = $tmp_message;
838 $subject = $tmp_subject;
839 }
840 }
841 if ($numemails == $tot_emails) {
842 print "Done!<br>";
843 }else if ($start_num >= $max_emails) {
844 print "Error: you forgot to increase the maximum number of emails.<br>";
845 $submit = "Send Message";
846 }else{
847 if ($max_emails) {
848 if (@$ffile) {
849 print 'Process has been paused ... <font color="#FF0000">NOTE: You must re-attach your attached file before resuming.</font><br>';
850 }else{
851 print 'Process has been paused ... <font color="#0000FF">Enter in the new Maximum number of emails and click the Resume button.</font><br>';
852 }
853 }
854 }
855 }
856}