Jump to content

Mass E-mail


mycro

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.
Link to comment
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]
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.