This little script adds potentially several files to an email. I receive the email but there is no body . If I remove the 'content-type' propery from the header then I at least get the body of the email, but the .jpg files are printed as garbage, and not displayed as a picture.
Any thoughts ?
Thanks...
$mailHeaders = "From: some dude <hello@test.com>\r\n";
$mailHeaders .= "Reply-To: yo@test.com\r\n";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$mailHeaders .= "MIME-Version: 1.0\r\n"."Content-Type: multipart/mixed;\r\n"." boundary=\"{$mime_boundary}\"\r\n";
$mailBody.="\n" ;
$mailBody=$mailBody."Service Name: $service_name \n";
$mailBody=$mailBody."The following errors were found in this service session. \n";
$mailBody=$mailBody."These files will not be created. \n\n";
for($x=0; $x < count($error_notice_array); $x++){
$mailBody=$mailBody."Filename: ".$error_notice_array[$x]->file_name."\n";
$error_msg=array();
$error_msg=$error_notice_array[$x]->error_msg;
for($i=0; $i < count($error_msg) - 1; $i++){
$mailBody=$mailBody.$error_msg[$i]."\n";
}
$array_num=count($error_msg);
$raw_file_name=$error_msg[$array_num - 1];
$mailBody=attachFile("/tmp/".$raw_file_name, $mailBody);
$mailBody=$mailBody."\n";
}
mail($email_address, $mailSubject, $mailBody, $mailHeaders);