I have a script that sends a canned email to an agency whenever a client completes our online course. It works 95% of the time but sometimes the email is not sent. At first I thought it was a spam filter but when I check my mail log it isn't even listed. It's is like it didn't make it to the mail server. I even code a small script to copy my mail command so that I could test the exact mail command and when I do it works. I'm at a complete loss at where to go from here. Below is a list of my code.
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Company Name<company@companyname.com>' . "\r\n";
$address = $getagency->email;
$result = mail($address,"Certificate of Completion",stripslashes($fname)." ".stripslashes($mname)." ".stripslashes($lname)." ".$uid." has finished the program on ".$completedate." at ".$completetime." Central time. You will find the student information, total time and date stamp in the Certificates Earned report. The post test score can be found in the Pre and Post Test report or in the student file. Bankruptcy Number: ".$getagency->banknum." District: ".$getagency->bankdist.".",$headers);
if($sresult) {}else{ mail("me@me.com","Mail failed","A message was not sent to ".$address." for ".stripslashes($fname)." ".stripslashes($mname)." ".stripslashes($lname)." on ".$completedate." at ".$completetime); }
Here is an example of one of the emails that did not go through.
mail(agency@agencyname.com,"Certificate of Completion",Anne M Leko 0212-00-zeaPT has finished the program on 2010-01-09 at 23:21 Central time. You will find the student information, total time and date stamp in the Certificates Earned report. The post test score can be found in the Pre and Post Test report or in the student file. Bankruptcy Number: 09-264 District: SD,MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: Company Name <company@companyname.com>
)
Any help would be greatly appreciated. I'm on a Windows 2008 server running PHP 5.0.67.