ajsuk Posted January 11, 2007 Share Posted January 11, 2007 Hey there, another nooby question I'm sure but again I'm stuck so I shall have to ask. ;)As the title says really, I'm looking to grab email addresses from a database to make up a recipients list for this email script...I've got this which does the job but having a script run 500 times over sending emails doesn't sound the best of ideas...[code]<db connect code etc...>while($row = mysql_fetch_array($result)){$to = $row['email'];$subject = "Test Email";$message = "Test Email Message";$from = "someone@mydomain.com";$headers = "From: $from";mail($to,$subject,$message,$headers);}mysql_close($con);?>[/code]Is there some way I can store the results in a variable to be used as the mail-to value for sending to all at once rather than one by one?Thanks for any help you can give! :) Quote Link to comment Share on other sites More sharing options...
Draicone Posted January 11, 2007 Share Posted January 11, 2007 Try this:[code]<?php// <db connect code etc...>while($row = mysql_fetch_array($result)){$mailto[] = array("to"=>$row['email'], "subject"=>"Test email", "message"=>"Test email message", "from"=>"someone@mydomain.com", "headers"=>"From: $from");}mysql_close($con);foreach($mailto as $mail) mail($mail['to'],$mail['subject'],$mail['message'],$mail['headers']);?>[/code]Hope this helps. Quote Link to comment Share on other sites More sharing options...
ajsuk Posted January 16, 2007 Author Share Posted January 16, 2007 Sorry for the delay, life got busy. Anyway, this didn't seem to work unfortunatly. :(Anything else I can do? :-\ Quote Link to comment Share on other sites More sharing options...
ajsuk Posted January 19, 2007 Author Share Posted January 19, 2007 *bump* :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.