wemustdesign Posted May 31, 2010 Share Posted May 31, 2010 I have a database of customers and want to create a script that will email them all at once. To do this would I use a while loop to run through all of the email addresses and send the emails or would there be a better way to do this? Quote Link to comment Share on other sites More sharing options...
ignace Posted May 31, 2010 Share Posted May 31, 2010 Loop through them, you could add them all to the To field however then your customers will know how many and who you have also as a customer. [ot]wemustdesign do you know your website has been reported as a potential attack website?[/ot] Quote Link to comment Share on other sites More sharing options...
iJoseph Posted May 31, 2010 Share Posted May 31, 2010 I think this will work: <?php $con = mysql_connect("localhost","hhh","hhh"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("Blah", $con); $result = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_array($result)) { $from = "From: <you@you.com> "; $to = " " . $row['email'] . " "; $subject = "title "; $message=" Message "; $message = stripslashes($message); if (mail($to,$subject,$message,$from)) { echo "Email sent"; } else { echo "MAIL FAILED"; } } mysql_close($con); ?> Sorry if it doesn't work, I havn't tested it. 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.