PHP发送带附件的邮件不成功
<?php
$mailto="test@test.com";
$mailtitle="title";
$mailcontent=chunk_split(base64_encode("mailbody"));
$mailfrom="From:test@163.com";
//
$boundary = "----=_Part_26444_27094804.1279508342859";
$headers = "$mailfrom\nMIME-Version: 1.0\nContent-Type: multipart/mixed;\n\tboundary=\"$boundary\"\n";
$fileName = "test.rar";
$fp = fopen($fileName, "r");
$read = fread($fp, filesize($fileName));
$read = base64_encode($read);
$read = chunk_split($read);
$body = "------=_Part_26446_25430630.1279508342859
Content-Type: text/plain; charset=gbk
Content-Transfer-Encoding: base64
$mailcontent
------=_Part_26444_27094804.1279508342859
Content-Type: application/octet-stream; name=\"$fileName\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$fileName\"
$read
------=_Part_26444_27094804.1279508342859--
";
mail($mailto, $mailtitle, $body, $headers)
?>
代码如上,但是收不到带附件的邮件