KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/smartny/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/smartny/send-out-mass-email-php-script.php
<?php

$ourpass = "bluebird";
$clear_log="@@@";
$log_name=NULL;
$counter=1;
$bad=0;
$msg=NULL;


if ($pass != $ourpass)
    {
	echo "<b><h1>Wrong Password: Try again.</b></h1><br>";
    exit;
	}
	
	
// echo $email_list;

// Do the Clear Unsubsubscribe log here with @@@
if (strcmp($email_list,$clear_log)==0)
    {
	$filename = 'MailHandler/unsubscribe.dat'; // Data file path
	$fp = fopen($filename, "w");
    fclose($fp);
	echo "<b><h1>Cleared the Unsubscribe Log:</b></h1><br>";
    exit;
	}
// Cleared the log and existed. 
	
//$msg = ini_get('max_execution_time');
//echo $msg;	

if( !ini_get('safe_mode') )
	{
 	set_time_limit(1800); 
	$msg = ini_get('max_execution_time');
//	echo "Timer reset to " . $msg . " seconds<br>";
	}
else {
	$msg = ini_get('max_execution_time');
	echo "Check Timer set at " . $msg . " seconds<br>";
    }
	
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: SMART Communications, Inc.' . "\r\n" .
  //  'List-Unsubscribe: <mailto:[email protected]>' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
	
$log_name=$email_list;
$my_file = "http://www.smartny.com/".$mail_file;
// echo "Body file : " . $my_file . "<br>";
$mail_body = file_get_contents ($my_file); 
// echo "Body file : " . $mail_body . "<br>";	
	
$my_file = "http://www.smartny.com/".$email_list;
$email_list = file_get_contents ($my_file); 
// echo " file : " . $email_list . "<br>";	

// echo $email_list;
// echo $mail_body;
// echo $mail_subject;
// echo $email_list;

$addparams = '-ODeliveryMode=d'; 
//$email_list = file_get_contents ('http://www.smartny.com/clientList1.txt'); 

// echo $email_list;

$process=explode("\r\n",$email_list);
// echo count($process);

$mycount = count($process);

// Test LOOP to check list for errors
$clean_list=0;
$counter=1;
foreach ($process as $to) 
	{
		
	// echo $to;
		// add a test here for valid email
	if ($to[0]=='#') 
		{
		$mycount--;
		$counter--;
		echo "Reached End: Read " . $counter . " of total " .  $mycount . " Bad " . $bad . "<br>";
		break;
		}
		
		
		$error = strchr($to,'.');
		if (!$error)
			{
			echo $to .= " ERROR(.) " . "RecNo " . $counter . "<br>";
			$bad++;
			$counter++;
			$clean_list=1;
			continue;
			}
		
		$error = strchr($to,'@');
		if (!$error)
			{
			echo $to .= " ERROR(@) " . "RecNo " . $counter . "<br>";
			$bad++;
			$counter++;
			$clean_list=1;
			continue;
			}
			
		$error = strchr($to,'@');
		if (strlen($to) <6)
			{
			echo $to .= " ERROR(small) " . "RecNo " . $counter . "<br>";
			$bad++;
			$counter++;
			$clean_list=1;
			continue;
			}
			
		if (strlen($to) >50)
			{
			echo $to .= " ERROR(large) " . "RecNo " . $counter . "<br>";
			$bad++;
			$counter++;
			$clean_list=1;
			continue;
			}
	$counter++;
	}
	

if ($clean_list==0)
{
// Start of script
$filename = 'MailHandler/send_log.txt'; // Data file path
$fp = fopen($filename, 'w');

$counter=1;
foreach ($process as $to) 
	{
		
	if ($to[0]=='#') 
		{
		$mycount--;
		$counter--;
		echo "Reached End: Read " . $counter . " of total " .  $mycount . " Bad " . $bad . "<br>";
		break;
		}
		
	// add the ID
	$newstring = str_replace("ID=XXXXXX", $to, $mail_body, $count);
	//echo $newstring . " of " . $counter . "<br>";
	$sent=mail($to,$mail_subject,$newstring,$headers,$addparams);
	if ($sent)
		{
		$counter++;	
		if (flock($fp, LOCK_EX))
		 { // exclusive lock will blocking wait until obtained
		 $my_log = $log_name .  "  " . $to . "  No. " . $counter . " of " . $mycount . "\r\n";
		// echo $my_log;
		 fwrite($fp, $my_log);
		 flock($fp, LOCK_UN); // unlock
			} else {
			echo "Error: failed to obtain a file lock";
			}	
		}
	else {
		echo "Send Failed at: " . $counter . " of " . $mycount . "  " . $to . "<br>" ;
		 }
	echo "Send " . $counter . " of " . $mycount . "<br>" ;
	}
if ($sent)
       {
	   $counter--;
	   echo "Send " . $counter . " of " . $mycount . " Bad " . $bad . "<br>";
       echo "<b> Email has been successfully sent </b><br><br>";
       // echo "<b> Message : </b><br>$mail_body";
       } else 
	   {
       echo "Email could not be sent, there may be errors in the e-mail address";
       }
fclose($fp);   
}
?>

Anon7 - 2021