PDA

View Full Version : php mail() problem



Robbie
20-01-2008, 08:52 PM
Hmm,

Why does this send the emails more than once, sometimes twice, four times, six times?


if ($_POST[send]) {
$email = $_POST["msg"];
$query = "SELECT * FROM `emailaddresses` ";
$result = mysql_query($query) or die (mysql_error()."<br />Couldn't execute query: $query");
$numrows = mysql_num_rows($result);

while($row = mysql_fetch_array($result)) {

$subject = 'Email';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($row[email], $subject, 'Test message', $headers);

}
}
Thats just the send email part.
Any help please?
Thanks

Jme
20-01-2008, 09:00 PM
Hmm,

Why does this send the emails more than once, sometimes twice, four times, six times?


if ($_POST[send]) {
$email = $_POST["msg"];
$query = "SELECT * FROM `emailaddresses` ";
$result = mysql_query($query) or die (mysql_error()."<br />Couldn't execute query: $query");
$numrows = mysql_num_rows($result);

while($row = mysql_fetch_array($result)) {

$subject = 'Email';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($row[email], $subject, 'Test message', $headers);

}
}
Thats just the send email part.
Any help please?
Thanks

Because it's going through the while loop and sending the email to every email int he database.. Your email must be in the database more than once?

lolwut
20-01-2008, 10:05 PM
Off Topic; how dod you get your server to send emails in the first place? I can't manage it.

Robbie
21-01-2008, 07:00 PM
Fixed myself thanks anyway. And PM me lolwut

MrCraig
21-01-2008, 07:22 PM
The server should automatically be able to send email if the server admin has configured pop3 correctly.

Want to hide these adverts? Register an account for free!