Jump to content

email mysql database


rotwyla98

Recommended Posts

I have a table set up like

ID | Name | Email
1  | Tom  | [email protected]
2  | Rick  | [email protected]
3  | Frank | [email protected]
..
1500 | Me | [email protected]

I am currently using the following code to email everyone on the list
[code]
<?php
$db_hostname    = 'localhost'; //Server where MySQL is running.
$db_user        = 'admin'; //Username to connect with.
$db_pass        = 'password'; //Password to connect with.
$db_name = 'list'; //Name of database to connect to.

$sql = mysql_connect($db_hostname, $db_user, $db_pass)or die("Connection Failure to Database");
mysql_select_db($db_name, $sql) or die ($db_name . " Database not found. " . $db_user);

$result = mysql_query("SELECT * FROM `users` WHERE `esent`= '0'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$name = $row['name'];
$email = $row['email'];

$to      = "$email";
$subject = "subject of the email";
$message = "Dear $name,\nHey guys. Hope you enjoyed the free XXXXXXXX\n\n
Well now I am opening up a new site at XXXXXXXX - It is going to have a XXXXXXXX.\n\n
I encourage you all to join!\n
Sincerely,\n
\t My Name\n

PS. If you have any suggestions, feel free to email me back.";
$headers = "To: $name <$email>" . "\r\n";
$headers .= "From: MyName <[email protected]>" . "\r\n";
mail($to, $subject, $message, $headers);
mysql_query("UPDATE `rune_users` SET `esent` = '1' WHERE `email`= '$email'");
echo "Sent to $email<br/>";
}

mysql_close($sql);
?>
[/code]

I doesnt seem to email everyone although it says that it has. I ran the script in a test table (3 users) and they got emails. When I do a big list (3k) and my email is last, I dont get one. I also received only about 3 hits in from emails so that tells me that not all of them were sent out.

Did I do something wrong?
Link to comment
https://forums.phpfreaks.com/topic/28035-email-mysql-database/
Share on other sites

[quote author=jawapro link=topic=115824.msg471718#msg471718 date=1164159104]
I'm not sure I want to help - sounds like a spammer to me  ???
[/quote]

Im not. Dont worry about that. If I was a spammer, I would email until XXX,XXX emails in the db and wouldnt be using this script.

I'm sending out these emails because I told the people I will be opening up a site and if they wanted me to email them when it went online. Now its online, I'm trying to send them an email and its not working =/
Link to comment
https://forums.phpfreaks.com/topic/28035-email-mysql-database/#findComment-128254
Share on other sites

I have no idea really. Could be anything from 20 - 1000 depending on the server and who set it up.

The only ways to tell would be to ask whoever was in charge, or just try it at 20, then 40, then 80, then 100, then 150 etc and see when it dosnt work. And when it dosnt work, start going backwards until it works again (with your email at the end - so if you get one, you know it works).

You said 3 worked, so at worst you could send three and then recall the same script - but that'd suck.
Link to comment
https://forums.phpfreaks.com/topic/28035-email-mysql-database/#findComment-128273
Share on other sites

Archived

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

×
×
  • 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.