Jump to content


Photo

Mass E-mail


  • Please log in to reply
4 replies to this topic

#1 mycro

mycro
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 27 September 2006 - 01:12 AM

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.

#2 mitzleah

mitzleah
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts
  • LocationManila, Philippines

Posted 27 September 2006 - 01:40 AM

after storing all email addresses to a variable:

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

#3 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 27 September 2006 - 03:01 AM

i think the best way of doing this would be:

<?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!');
}
?>


#4 scheols

scheols
  • Members
  • PipPipPip
  • Advanced Member
  • 113 posts

Posted 27 September 2006 - 03:05 AM

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]

<?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 } ?>

Dont Piss me Off today

#5 mycro

mycro
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 27 September 2006 - 04:08 AM

Thanks all!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users