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