Can any one explaine why this code can't send zip-files, but work ok for xml and xls files?
The function call return OK, but I don't receive any mail.
The function call return OK, but I don't receive any mail.
Code:
<?php
function mail_attachment($filename, $userfile, $mail_to, $from_mail, $from_name, $replyto, $mail_subject, $message)
{
$fp = fopen($userfile, "rb");
$file = fread($fp, filesize($userfile));
fclose($fp);
$file = chunk_split(base64_encode($file));
$mail_boundary = md5(uniqid(time()));
$mail_boundary = "==Multipart_Boundary_x{$mail_boundary}x";
$mail_headers = "From: \"".$from_name."\" <".$from_mail.">\r\n";
$mail_headers .= "Reply-To: <".$from_mail.">\r\n";
$mail_headers .= "MIME-Version: 1.0\r\n";
$mail_headers .= "Content-type: multipart/mixed;boundary=\"{$mail_boundary}\"\r\n";
$mail_headers .= "\r\n";
$mail_body = "--{$mail_boundary}\r\n";
$mail_body .= "Content-type: text/plain; charset=euc-kr\r\n";
$mail_body .= "Content-transfer-encoding: 8bit\r\n";
$mail_body .= "\r\n";
$mail_body .= "$message";
$mail_body .= "\r\n";
$mail_body .= "--{$mail_boundary}\r\n";
$mail_body .= "Content-type: application/octet-stream; name=$filename\r\n";
$mail_body .= "Content-transfer-encoding:base64\r\n";
$mail_body .= "\r\n";
$mail_body .= $file;
if (mail($mail_to, $mail_subject, $mail_body, $mail_headers))
{
echo "OK";
}
else
{
echo "ERROR";
}
}
?>
Comment