有人可以幫我弄清楚爲什麼這會一直返回false?PHP郵件()附件問題
$to = "[email protected]";
$from = "Website <[email protected]>";
$subject = "Test Attachment Email";
$separator = md5(time());
// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;
// attachment name
$filename = "document.pdf";
//$pdfdoc is PDF generated by FPDF
$attachment = chunk_split(base64_encode($pdfdoc));
// main header
$headers = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;
// message
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= $message.$eol.$eol;
// attachment
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";
// send message
if (mail($to, $subject, "", $headers)) {
echo "mail send ... OK";
} else {
echo "mail send ... ERROR";
}
我已經看到這個「把所有內容放在'$ headers'」幾天前。你們從哪裏複製粘貼它? – 2011-06-08 06:42:35
此手冊標題操作是一個骯髒的解決方案。就我個人而言,我是Zend_Mail的粉絲,儘管我想知道其他任何「智能」方法。 – 2012-08-03 19:18:52
@MattH,Zend開發人員不必也這樣做「髒解決方案」呢? – 2013-09-30 18:50:09