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 <nstangle@maddogmania.com>";
$reply = "nstangle@maddogmania.com";
$headers = 'From: '  . $from . "\r\n";
$headers .= 'Reply-to: '  . $reply . "\r\n";
$headers .= 'BCC: blast@maddogmania.com' . "\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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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