I have a site that has about 60 sponsors or so, who provided needed information for the visitors to my site. Visitors can submit information requests to my sponsors via a form on my web site. In the form processing, here is the progression:
- Checks to make sure the email is valid
- Checks to make sure that the required fields are filled.
- Checks to make sure it is not a duplicate submission.
- Writes the data to the database
- Sends a copy of the email out to each sponsor.
Everything from steps 1-4 above happen instantly. The problem is when the mail has to go out. It is taking too long to send out individual emails to each sponsor. The page is timing out. Here's the way I have the code set.
$arRecipient = array();
$recct = 0;
$getemaillist = "SELECT addr FROM lists";
$getemailrec = mysql_db_query($dbname,$getemaillist);
while ($qryemails = mysql_fetch_array($getemailrec)){
$arRecipient[$recct] = trim($qryemails[emailaddress]);
$recct++;
}
foreach($arRecipient as $rec){
mail($rec, $subject, $aemailbody, "From:".$sender."\nReply-To:".$sender."\n");
}
How can I get the mail to send out much more quickly so that the thank you page is returned immediately to the visitor?