Jump to content

php mail()


sstangle73

Recommended Posts

Hey,

I have a system set up where it selects from a database and sends an email to everyone. But the problem I am having is that it sends every email twice. I am not quite sure why it does that. Also, it takes the page FOREVER to load. Could someone help me to fix/optimize this code?

Thanks!

 

edit:

Sometimes the browser comes back with this instead of a success message:

No data received

Unable to load the webpage because the server sent no data.

Here are some suggestions:

·        Reload this web page later.

Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

$query="SELECT * FROM `" . $table . "` WHERE status LIKE 'Accepted%'"; 
$result=mysql_query($query); 
while($array=mysql_fetch_assoc($result)){
$coach_email = $array['coach_email'];
$contact_email = $array['contact_email'];
$to = $coach_email . ", " . $contact_email;
$subject = $_POST["subject"];
$message = $_POST["message"];
$message = stripslashes($message);
$from = "Mad Dog Mania Showcase Tournament <[email protected]>";
$reply = "[email protected]";
$headers = 'From: '  . $from . "\r\n";
$headers .= 'Reply-to: '  . $reply . "\r\n";
$headers .= 'BCC: [email protected]' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$subject,$message,$headers);	
}
$success=true;

Link to comment
https://forums.phpfreaks.com/topic/239300-php-mail/
Share on other sites

You can call an operating system program using exec().  So you could make a simple script that runs the script using exec and displays a message stating that it was run. 

 

Something like this:

 

exec('/usr/bin/php -f /path/to/script/yourscript.php &');

Link to comment
https://forums.phpfreaks.com/topic/239300-php-mail/#findComment-1229700
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.