• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

07 DB Into mass emailer

Newbie Spellweaver
Joined
Oct 19, 2010
Messages
9
Reaction score
0
Hey guys I have an 07 GunZ Database my old one with about 8-9k Emails
Would anyone have a script or program to send Theys emails out :O?
 
Good Guy George
Loyal Member
Joined
Apr 12, 2009
Messages
1,260
Reaction score
239


I have no knowledge about sql and php, but i would do a script that sens my message to all via collecting their email from db.
 
Upvote 0
Pee Aitch Pee
Joined
Mar 30, 2011
Messages
630
Reaction score
422
SELECT Email FROM Account, loop through it and send the mail to the email.
 
Upvote 0
Good Guy George
Loyal Member
Joined
Apr 12, 2009
Messages
1,260
Reaction score
239
PHP:
$data = mysql_query("SELECT Email FROM Account") 
<?php
 $to = $data;
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";
 if (mail($to, $subject, $body)) {
   echo("<p>Message successfully sent!</p>");
  } else {
   echo("<p>Message delivery failed...</p>");
  }
 ?>
Is this right :p ? SuperWaffle?
 
Upvote 0
DRGunZ 2 Creator
Loyal Member
Joined
Jan 21, 2007
Messages
4,493
Reaction score
161
Use a while statement to loop through all results from the DB
 
Upvote 0
Joined
Sep 1, 2011
Messages
453
Reaction score
191
The Bellow Script will send the exact same message to everyone.
PHP:
<?php

//run query to get emails
$query = mssql_query('SELECT Email FROM Account');

$data = array();

while($row = mysql_fetch_array($query)) {
    $data[] = $row['email'];
}

//will seperate emails by comma so they can all be sent as once
$to = implode(", ", $data);

//from
$from = "no-reply@yourwebsite.com";

//reply_to
$reply_to = "whodoyouwanttheusertoreplyto@yourwebsite.com";

//Email Headers
$headers  = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($repy_to) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

//Email Subject
$subject = "Test mail";

//Message May Include HTML sense its content type is defined as text/html in header
$message = "<b>Hello!</b><br /> This is a simple email message.";

mail($to,$subject,$message,$headers);

?>


I coded this without testing so ya, but I for that amount of emails I would use, PHPMailer or something that works well with sending bulk emails.

EDIT:
If you want to send customized messages to every user (like username in email) you can do so by,
PHP:
<?php

//run query to get emails
$query = mssql_query('SELECT * FROM Account');

//from
$from = "no-reply@yourwebsite.com";

//reply_to
$reply_to = "whodoyouwanttheusertoreplyto@yourwebsite.com";

//Email Headers
$headers  = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($repy_to) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

//I would put subject here if its not different for every user else u can put it in the while() loop.
$subject = "Test mail";

while($row = mysql_fetch_array($query)) {
    //Email Subject
    $message = "<b>Hello!</b><br /> This is a simple email message. <br />Your username is". $row['UserID'];
    mail($row['email'],$subject,$message,$headers);
}

?>
 
Last edited:
Upvote 0
Experienced Elementalist
Joined
Feb 15, 2007
Messages
206
Reaction score
137
send just 30 emails you will get blacklisted for the spam filters
 
Upvote 0
Back
Top