Hi all, this forum proved to be awesome for helping me with my previous query so I'm hopeful it can do so again. I'm a newbie to PHP and it's a lot to take in but I'm really enjoying it so far. It opens up so many possibilities compared to a html only site.
Anyway... I have managed to put together a simple email script which is tested and working. The thing is, I'm currently using my test table which has 3 email addresses in it. The real table has over 2000 members. I've never emailed them in one go before but when I do, I want to make sure the script is going to work! The last thing I want is for it to crash or time out and some members get one email, some get two and some don't get anything. I have read that I may have a problem with using mail() for large lists.
Should I modify my current script? If so, in what way? I'm really dumb at PHP at the moment so please be gentle. Any help would be much appreciated!
Current Script
<?php
include("../../opendb.php");
mysql_select_db($dbname1);
$mailtable = $_POST['table'];
$mailsubject = $_POST['subject'];
$mailmessage = stripslashes($_POST['message']);
$sql="SELECT * FROM $table";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
$name = $rows['name'];
$to = $rows['email'];
$subject = "$mailsubject";
$header = "from: Me <me@domain.com>";
$message = "Dear $name \r\n";
$message.= " \r\n";
$message.= "$mailmessage \r\n";
$message.=" \r\n";
$message.="Warmest Regards \r\n";
$message.="Me \r\n";
$sentmail=mail($to,$subject,$message,$header);
}
if($sentmail){
header("location:http://www.domain.com/success.html");
}
else {
header("location:http://www.domain.com/failure.html");
}
include("../../closedb.php");
?>