fja3omega Posted May 18, 2010 Share Posted May 18, 2010 I'm currently trying to use this script to send email with different content to different emails. The problem I am having is that once it reaches about 90 emails it suddenly stops. I don't know if the problem is the bandwidth of the domain or the script itself. Can someone help me with this please. Thank you. $result = mysql_query("SELECT * FROM table1"); while($row = mysql_fetch_array($result)) { $email = $row['Email Address']; $company = $row['Company']; $cntperres = mysql_query("SELECT * FROM table2 WHERE `Email Address`='$email'"); while($cntperrow = mysql_fetch_array($cntperres)) { $cntper = $cntperrow['Contact Person']; } # -=-=-=- MIME BOUNDARY $mime_boundary = "----BEYOND SHIPPING----".md5(time()); # -=-=-=- MAIL HEADERS $to = $email; $subject = "MAIL for " . $company; $headers = "From: [email protected]\n"; $headers .= "Reply-To: [email protected]\n"; $headers .= "CC: [email protected]\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n"; $message .= "--$mime_boundary\n"; $message .= "Content-Type: text/html; charset=UTF-8\n"; $message .= "Content-Transfer-Encoding: 8bit\n\n"; $message .= "<html>\n"; $message .="<p>Dear <strong>"; $message .= $cntper; $message .="</strong>,</p>"; $message .= 'message1'; $result2 = mysql_query("SELECT * FROM `table1` WHERE `Email Address`='$email'"); while($row2 = mysql_fetch_array($result2)) { $message .= "message2 selected from table1"; } $message .= 'message3'; $message .= 'message4'; $message .= "<p></p>"; $message .= "</body>\n"; $message .= "</html>\n"; # -=-=-=- FINAL BOUNDARY $message .= "--$mime_boundary--\n\n"; # -=-=-=- SEND MAIL $mail_sent = @mail( $to, $subject, $message, $headers ); if($mail_sent) { echo "\nmail sent to " . $email; } else { echo "\nmail not sent to " . $email; } } Any suggestions would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/202144-mass-mail-problem/ Share on other sites More sharing options...
kenrbnsn Posted May 18, 2010 Share Posted May 18, 2010 You are probably exceeding the maximum execution time for PHP on your host. See set_time_limit. Ken Quote Link to comment https://forums.phpfreaks.com/topic/202144-mass-mail-problem/#findComment-1060113 Share on other sites More sharing options...
fja3omega Posted May 19, 2010 Author Share Posted May 19, 2010 okay i will try adding this to the code then... hmmm... yup its probably php execution time... had the same problem with my tables... Thank you... Quote Link to comment https://forums.phpfreaks.com/topic/202144-mass-mail-problem/#findComment-1060364 Share on other sites More sharing options...
katierosy Posted May 19, 2010 Share Posted May 19, 2010 If it fails after increasing the maximum execution time limit in php, you may contact webhosting provider if you are on a shared hosting environment. Quote Link to comment https://forums.phpfreaks.com/topic/202144-mass-mail-problem/#findComment-1060536 Share on other sites More sharing options...
bulrush Posted May 19, 2010 Share Posted May 19, 2010 Just after the WHILE begins, do this: $message=""; You are never initializing $message, that could be the problem. $headers is initialized, but $message is not. Quote Link to comment https://forums.phpfreaks.com/topic/202144-mass-mail-problem/#findComment-1060581 Share on other sites More sharing options...
fja3omega Posted May 20, 2010 Author Share Posted May 20, 2010 Hmmm... didn't even see that... thanks bulrush... $message=""; Quote Link to comment https://forums.phpfreaks.com/topic/202144-mass-mail-problem/#findComment-1060915 Share on other sites More sharing options...
dpacmittal Posted May 20, 2010 Share Posted May 20, 2010 Add set_time_limit(0); ini_set('memory_limit', '64M'); at the top of the file. Also initialize $message as pointed by bulrush. Quote Link to comment https://forums.phpfreaks.com/topic/202144-mass-mail-problem/#findComment-1060976 Share on other sites More sharing options...
fja3omega Posted May 20, 2010 Author Share Posted May 20, 2010 Okay... its still not working... it still stops... must be the execution time set on my server... have decided to split this into little bits... maybe split the emails by 50 email sending each run... does anyone have a clue how to automatically open a new page or redirect the page to a different page after running this kind of script? without clicking on a link or button... thank you. Quote Link to comment https://forums.phpfreaks.com/topic/202144-mass-mail-problem/#findComment-1061200 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.