Bulk Email Problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I coded a bulk emailer for our newsletter that worked fine for the last few 
years resulting in many requests for forgotten passwords and renewed site 
activity. 

Last year, we sent it again, after a few minor code changes, and had no 
response whatsoever. Unfortunately, I no longer have the backup copy of the 
original code. So, I assume that the code has an error that I can't see.

Perhaps someone might see an obvious error in the code (I'm just too close to 
it to see it objectively. The code page loads from a secured authorized 
connection, and iterates through a postgresql db table for names and email 
addresses. I've broken the email packets to 50, and verify that each has been 
sent. Any help greatly appreciated -- I'm afraid to check it live with actual 
names/email addresses, though it works fine for a few duds that I have salted 
in the sponsor table.


Code snippet:

<?php

if ($_POST['submit'] == "Next Batch?"){

	$run = $_SESSION['run'];

	/* DEBUG PRINT STATEMENTS */
		
		print "<h4>POST submit value is {$_POST['submit']}</h4><br<br>";
		print "<h4>RUN value is $run</h4><br<br>";
		print "<h4>RUN SESSION value is {$_SESSION['run']}</h4><br><br>";
	
	include("dbc.php");
			
	switch ($run) :
		
		case "1" :
		/* sid to 100-149 */

			$current = "(SID 100-149)";
			$query = "SELECT sid,sfname,ssname,smail FROM sponsor WHERE sid > 99 AND 	
sid < 150
			AND sid != 100 AND sid != 105 AND sid != 107 AND sid != 109 AND sid != 111 
AND sid != 113
			AND sid != 114 AND sid != 119 AND sid != 130 AND sid != 131 AND sid != 148 
AND sid != 165 AND sid != 166
			ORDER BY sid ASC";
			$run = 2;
			$_SESSION['run'] = 2;
			session_write_close();
			break;


		case "2" :
		/* sid to 150-199 */

			$current = "(SID 150-199)";
			$query = "SELECT sid,sfname,ssname,smail FROM sponsor WHERE sid > 149 AND 
sid < 200
			AND sid != 100 AND sid != 105 AND sid != 107 AND sid != 109 AND sid != 111 
AND sid != 113
			AND sid != 114 AND sid != 119 AND sid != 130 AND sid != 131 AND sid != 148 
AND sid != 165 AND sid != 166
			ORDER BY sid ASC";
			$run = 3;
			$_SESSION['run'] = 3;
			session_write_close();
			break;

			. . . .

		case "11" :
		/* sid 500 + */

			$current = "(SID 600+)";
			$query = "SELECT sid,sfname,ssname,smail FROM sponsor WHERE sid > 599
			ORDER BY sid ASC";
			$run = 12;
			$_SESSION['run'] = 12;
			session_write_close();
			break;


		case "12" :

			$run = "'s complete!";
			header("location: newsletter.php");
			break;


		case "TEST RUN";
	
			print "TEST RUN: NO further processing<br>Check incoming email!";
			break;

	endswitch;


	/* Text and headers for email */

	$message = "Dear $fname,

			...... admin";


	$sender = "sent@xxxxxxxx";
	$subject = "Newsletter June 2008";
	
	$recipient_fullname = "$fname $sname";
	$recipient = "$recipient_fullname <$smail>";
	
	// call mail function
	
	$headers = "From: $sender";
	$response = mail($recipient, $subject, $message, $headers);

		if ($response[0] == 0) { 
			print "<h4><br><br>Run #$run-$current Newsletter email processed for 
($sid) - $fname $sname<br>$smail<br><br></h4>";
		}
		else {
			print "<h4><br><br>Run #$run-$current ERROR processing for ($sid) - $fname 
$sname<br>$smail<br><br></h4>";
		}

	}

}

?>

Tia,
Andre
(celtic)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux