What is the most efficient way to mass mail a bunch of users with php? I have a bunch of names, usernames and emails in a database and am writing a script to send an email to all of the users in that database. Currently, I am using this method:
This is an open source script, and I do not know how many user's people would have, so I am going to use 5,000. Do you think this would work to send an email to 5,000 people?PHP Code:for($i=0;$i < mysql_num_rows($result);$i++){
$body = $message . "\n\n" . $footer;
$body = str_replace('%name%',$name[$i],$body);
$body = str_replace('%date%',$date[$i],$body);
$body = str_replace('%email%',$email[$i],$body);
$body = str_replace('%username%',$username[$i],$body);
$body = str_replace('%remove%',$url.'/remove.php',$body);
if(!mail($email[$i],$subject,$body)){
die('There was an error while sending the email to '.$email[$i].'. Please make sure the PHP mail function is configured on your server.');
}
}
Also, where I have the strreplace multiple times, I am trying to replace certain strings in the message with various pieces of information. Is there a way to do this more efficiently? I don't know why, but I just have a feeling that someone is going to get to this code and the script is just going to quit on them.






Bookmarks