I have created a custom mailing list and want to know how to track which emails are sent and which ones bounce in my script, rather than just having to login to my webmail and look to see if any bounced. The ones that bounce, I want to be displayed to the screen so I may remove them from the database if they are no good. So basically, I want it to show how many emails were sent total, how many were successful and how many failed.
Does anyone know how to track this using PHP?
This is my code to send the emails to everyone in the list and track how many were sent:
if($_POST['subject'] && $_POST['message']){
$sql = "SELECT *
FROM subscribers";
$res = mysql_query($sql);
$counter = 0;
while($sub = mysql_fetch_array($res)) {
$useremail=$sub['email_addr'];
$subject="$subject";
$header = "From: [email]band@roundtree.com[/email]\r\n";
$header .= "X=Mailer: PHP/";
$body="
Hello ".$sub['name'].",
$message
[url]www.round-tree.com[/url]
To be removed from this list, please visit [url]www.round-tree.com/unsubscribe.php[/url]";
mail ($useremail, $subject, $body, $header);
$counter++;
}
$success = true;
$subject = "";
$message = "";
}
}
Also, does anyone know of some code to validate email addresses that works well? I want to add some to my script to make sure somebody doesn't just type anything. Right now it only checks to make sure the field isn't empty.
Thanks in advance for your help.