I have written a mass mailer that sends a message for each address in a file.
It works beautifully, but I am worried about sendmail failing in the middle of a large list(about 2000)
I am wondering if sendmail fails can i log the address where sendmail failed..so I don't end up sending duplicate emails.
here is my code:
if($submit === "send"){
if(!$sent){
echo "Book is empty!";
} else {
//upload file
$k = $HTTP_POST_FILES['message']['name'];
$r = $HTTP_POST_FILES['message']['tmp_name'];
if(!$k){
echo "You didn't pick a file!!";
} elseif(file_exists("$k")){
echo "$k already exists..Rename your file!!";
} else {
copy($r,$k) or die ("fail!!");
$q= fopen($k, 'r');
while(! feof($q)){
$msg = fgets($q, 1024);
}
unlink($k);
//send mail
$MFrom = "me@somewhere.org";
$header .= "Content-type: text/html; charset=iso-8859-1";
$MailSubject = "MY_SUBJECT";
echo "<h3>SENT TO:</h3>";
while(list($key, $value) = each($sent)){
foreach($sent as $val){
echo "$val<br>";
mail($val,$MailSubject,$msg,"$header\nFrom: $MFrom\n");
}}}}}
any help would be appreciated.