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? Link to comment https://forums.phpfreaks.com/topic/203412-mass-email-script/ 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] Link to comment https://forums.phpfreaks.com/topic/203412-mass-email-script/#findComment-1065614 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: <[email protected]> "; $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. Link to comment https://forums.phpfreaks.com/topic/203412-mass-email-script/#findComment-1065765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.