i found this code to send an attachment with an e-mail on php.net, when the attachment is a .jpg, the program works, but if i try to send a .txt file or .doc or .htm, the email doesnt get sent, but there's no error messages either. here's the code:
$from = "From: Me <me@mydomain.com>\r\n";
$subject = "Requested Information";
$message = "The requested information is in the attaced file.";
$file = "doc1.doc";
function mail_attach($email, $from, $subject, $message, $file) {
/this function was taken from php.net and was written by Jan Philipp Fiedler/
$mime_boundary = "<<<:" . md5(uniqid(mt_rand(), 1));
$data = chunk_split(base64_encode(implode("", file($file))));
$header = "From: ".$from."\r\n";
$header.= "To: ".$email."\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: multipart/mixed;\r\n";
$header.= " boundary=\"".$mime_boundary."\"\r\n";
$content = "This is a multi-part message in MIME format.\r\n\r\n";
$content.= "--".$mime_boundary."\r\n";
$content.= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$content.= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$content.= $message."\r\n";
$content.= "--".$mime_boundary."\r\n";
$content.= "Content-Disposition: attachment;\r\n";
$content.= "Content-Type: Application/Octet-Stream; name=\"".$file."\"\r\n";
$content.= "Content-Transfer-Encoding: base64\r\n\r\n";
$content.= $data."\r\n";
$content.= "--" . $mime_boundary . "\r\n";
if(mail($email, $subject, $content, $header)) {
return TRUE;
}
return FALSE;
}
mail_attach($email, $from, $subject, $message, $file)
or die ("mail_attach error");
can anyone figure help me figure out why the .jpgs go through but others will not?
thanks ~JOSH😕