Jump to content

Archived

This topic is now archived and is closed to further replies.

mycro

Mass E-mail

Recommended Posts

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.

Share this post


Link to post
Share on other sites
after storing all email addresses to a variable:

$to = implode(",", $array);
mail($to, $subject, $message, $headers);

Share this post


Link to post
Share on other sites
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: NOREPLY@blabla.com\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]

Share this post


Link to post
Share on other sites
[code]Yep that is the best way I made one of these about an 2 hours ago.
function/inputsettings.php
[code]
<?php
function inputsettings($value,$type,$name){
return '<input type="'.$type.'" value="'.$value.'" name="'.$name.'">';
}
?>
[/code]

[/code]
[code]
<?php
include("./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>
<?php
echo "<center>".inputsettings('submit','submit','massemail')."</center>";
?>
</form>
<?php } ?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.