Jax2 Posted April 8, 2010 Share Posted April 8, 2010 Hi everyone. I'm trying to help a client set up an email cronjob to send out emails telling his employees they need to contact a certain company each day, depending on the contact date. I wrote my script, tested it the first time and found out I had an error, and for each of the 18 contacts that had to be sent out today, I sent 18 of them... for a total of 324 emails. Oops. I corrected the error and tried it again and this time it sent me all 18 contacts just as it should. I tried it a third time and now it won't send anything at all, or at least, I'm not getting anything. I have tried removing the mail() function and simply echoing each thing onto the page, and I'm getting all the correct data ... (As in, $to, $subject, $body, $headers) ... they show up perfect, but if I try and mail them again, no emails are being sent. Here is the script. Some fast help would be appreciated! <?php include("includes/db.php"); $today=date('Y-m-d'); $from="XXXX@XXXXX.XXX"; $to="XXXX@XXXXX.XXX"; $subject="Contact call backs for ".$today.""; $headers = 'From: '.$from.'' . "\r\n" . 'Reply-To: '.$from.'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $sql="SELECT * FROM prospects WHERE contact_next='$today'"; $result=mysql_query($sql, $db); $total=mysql_num_rows($result); if ($total<1) { die(); } ELSE { while ($row=mysql_fetch_array($result)) { $body=" ".$row['representative'].",\r\n The following company is scheduled for a call-back today, ".$today.".\r\n Company: ".$row['company_name']."\r\n Name: ".$row['firstname']." ".$row['lastname']."\r\n Address: ".$row['address']."\r\n City: ".$row['city'].", ".$row['province']."\r\n Phone: ".$row['phone']."\r\n Email: ".$row['email'].""; mail($to, $subject, $body, $headers); } } ?> Again, if I remove mail( and simply echo $to, $subject, $body, $headers, they all show up as correct. So, they SHOULD be getting sent out. Quote Link to comment Share on other sites More sharing options...
the182guy Posted April 8, 2010 Share Posted April 8, 2010 Have you tried a different email address to send to? These days spam filters can be very strict. By doing that you can rule out a problem with the receiving email provider. Quote Link to comment Share on other sites More sharing options...
Jax2 Posted April 8, 2010 Author Share Posted April 8, 2010 I have changed the $to email address to 3 different ones now, nothing helps. Quote Link to comment Share on other sites More sharing options...
the182guy Posted April 8, 2010 Share Posted April 8, 2010 Is the script running on your own computer, or is it a webhost, or dedicated server? The reason I ask is because the webhost could have changed the PHP mail settings, or even blocked your account from sending mail due to the 300+ in one go error. Quote Link to comment Share on other sites More sharing options...
Jax2 Posted April 8, 2010 Author Share Posted April 8, 2010 I found the problem ... apparently dreamhost, in their infinite wisdom, deemed it necessary to prevent anyone from sending out more than 100 emails in an hour. Therefore, the first 324 I tried to send threw me over the hourly limit, and even though I was only trying to send 18 each time after, I was already suspended for the hour. What a pile of junk. Hope I never need to send out newsletters to more than 100 people at a time :/ Quote Link to comment Share on other sites More sharing options...
Jax2 Posted April 8, 2010 Author Share Posted April 8, 2010 Is the script running on your own computer, or is it a webhost, or dedicated server? The reason I ask is because the webhost could have changed the PHP mail settings, or even blocked your account from sending mail due to the 300+ in one go error. You were right, of course. Thanks! If I hadn't contacted my host to bitch at them already, that would have helped a lot Quote Link to comment Share on other sites More sharing options...
the182guy Posted April 8, 2010 Share Posted April 8, 2010 Is the script running on your own computer, or is it a webhost, or dedicated server? The reason I ask is because the webhost could have changed the PHP mail settings, or even blocked your account from sending mail due to the 300+ in one go error. You were right, of course. Thanks! If I hadn't contacted my host to bitch at them already, that would have helped a lot Nice one, glad you solved it. Quote Link to comment Share on other sites More sharing options...
PhpScripts Posted April 8, 2010 Share Posted April 8, 2010 I'm glad you solved it! I had the issue awhile back I started a directory on a site which automatically sent out email once the links were approved. I didn't check with my host and after I accepted 500 links at one time my host closed my account for violation of policies. :'( Quote Link to comment 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.