mycro Posted September 27, 2006 Share Posted September 27, 2006 I need to send an e-mail to all of my users in my database to inform them of an update. I have the field "email" in my user table, but the problem is that I have about 40,000 users on my site that I need to inform. What would be the best way to do this? Thanks. Link to comment https://forums.phpfreaks.com/topic/22189-mass-e-mail/ Share on other sites More sharing options...
mitzleah Posted September 27, 2006 Share Posted September 27, 2006 after storing all email addresses to a variable:$to = implode(",", $array);mail($to, $subject, $message, $headers); Link to comment https://forums.phpfreaks.com/topic/22189-mass-e-mail/#findComment-99352 Share on other sites More sharing options...
BillyBoB Posted September 27, 2006 Share Posted September 27, 2006 i think the best way of doing this would be:[code]<?php$query = mysql_query("SELECT * FROM user");while($user = mysql_fetch_assoc($query)) { $to = $user['email']; $subject = "This is the subject"; $message = "This mail is going out to all my members..."; $headers = "From: [email protected]\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n"; mail($to, $subject, $message, $headers)or die('The email could not send!');}?>[/code] Link to comment https://forums.phpfreaks.com/topic/22189-mass-e-mail/#findComment-99374 Share on other sites More sharing options...
scheols Posted September 27, 2006 Share Posted September 27, 2006 [code]Yep that is the best way I made one of these about an 2 hours ago.function/inputsettings.php[code]<?phpfunction inputsettings($value,$type,$name){return '<input type="'.$type.'" value="'.$value.'" name="'.$name.'">';}?>[/code][/code][code]<?phpinclude("./config.php");require_once("./functions/inputsettings.php");if($logged[username] != 5){echo "Sorry you do not have permissions to view this area";exit;}$subject = $_POST['subject'];$message = $_POST['message'];$sendmasse = $_POST['massemail'];$uone = mysql_query("SELECT * FROM users WHERE id='1' ") or die(mysql_error());$adminone = mysql_fetch_array($uone);$admin = $adminone[email];$adminname = $adminone[username];if(isset($sendmasse)){$user_emails = mysql_query("SELECT * FROM users") or die(mysql_error());while($alluseremails = mysql_fetch_array($user_emails)){$allusers = $alluseremails[email];mail($allusers,$subject,$message,"From: "."Webmaster - $adminname"."<".$admin.">\n");}}else{?><form method='post'><table border='1' width='100%'><tr><td style='text-align: center;'>Send email</td></tr></table><table border='1' width='100%' colspan='2'><tr><td><center>Subject</center></td><td><center><input type='text' name='subject' size='27'></center></td></tr><tr><td><center>Message</center></td><td><center><textarea name='message'></textarea></center></td></tr></table><?phpecho "<center>".inputsettings('submit','submit','massemail')."</center>";?></form><?php } ?>[/code] Link to comment https://forums.phpfreaks.com/topic/22189-mass-e-mail/#findComment-99375 Share on other sites More sharing options...
mycro Posted September 27, 2006 Author Share Posted September 27, 2006 Thanks all! Link to comment https://forums.phpfreaks.com/topic/22189-mass-e-mail/#findComment-99399 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.