View Full Version : DB - how to email ALL memebers in it?
Hi guys,
Could someone give me an idea how i could email ALL the members in my sites DB?
is it possible? its a mysql DB and it has 400+ members that i dont want to email individually LOL (to much copy and pasting)
Thanks a mill :)
Everton
BerksWebGuy
10-4-05, 10:03 AM
I guess you have a few options:
One would be to export it into a comma delimited file, and send it out that way.
Or you can use PHP and do a mysql query loop to pull out each email and then mail it.
Or you can use PHP and do a mysql query loop to pull out each email and then mail it.
you lost me on query loop, i never dared to play with that.
is there any scripts that i can use to pull it,
also i cant seem to find the powweb mail server thing, can you point me towards it please.
thanks again buddy.
BerksWebGuy
10-4-05, 11:53 AM
Very quick, dirty, and un-tested:
<?
mysql_connect("mysql01.powweb.com", "username", "password") or die(mysql_error());
mysql_select_db("db_name") or die(mysql_error());
$counter = 0;
$result = mysql_query("SELECT * FROM table_name") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$sendit = $row['email'];
$counter++;
echo $sendit . "<br>";
mail( $sendit , "Subject goes here" , "Put your message in here\n\nor anything else", "From: You<you@yoursite.com>");
}
echo $counter;
?>
This also prints out to the screen all the emails you sent it to, and at the end, the count.
And what do you mean by mail server thing??
RTH10260
10-4-05, 12:33 PM
also i cant seem to find the powweb mail server thing, can you point me towards it please.In php you can use the easy mail() function. As this sends directly from the webserver at Powweb, these mailings tend to get handled as spam and discarded.
A better approach is to use a package of routines like phpmailer and use the smtp mail server of the own domain. The sender is then correctly identified as being your domain.
http://phpmailer.sourceforge.net/
If you haven't done so, add the SPF identification record to your DNS (in OPS).
thanks BWG i looked at your code i added it to the server and filled in the reds i got this message
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
is that this line: $result = mysql_query("SELECT email FROM $tab[users]") or die(mysql_error());
??
thanks
BerksWebGuy
10-4-05, 02:49 PM
$tab[users] is wrong. It should be the table name in the database.
Please be very very careful with mass-mailing.
If your DB contains e-mail address of people who doesn't want your mail, you can have trouble
and you can cause problem for other users...
its for my game, im giving out details, its not mass mailing garbage,
thanks for your help guys :)
it hasnt worked yet but i will keep trying.
RTH10260
10-4-05, 11:07 PM
it hasnt worked yet but i will keep trying.If you need a concise turtorial with the most important features to get you up to speed, check this:
Tizag Tutorials: http://www.tizag.com/
vBulletin v3.6.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.