$content = chunk_split(base64_encode(file_get_contents('test.dpa')));
$uid = md5(uniqid(time()));
$header = "From: mail@mail.com\r\nReply-To: mail@mail.com\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $msg."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream; name=\"test.dpa\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"test.dpa\"\r\n\r\n";
$header .= $content."\r\n\r\n";
if( mail($_POST['email'], 'TESTING MAIL', "", $header ) )
echo "SUCCESS !";
else
echo "NOPE !";
我想发送带附件的邮件。我正在填写完整表单中的$msg
格式。 - test.dpa - 是一个文件。
我的问题在于声明。为什么声明是假的?如果我想发送邮件,我会得到“NOPE”结果。但为什么?问题出在哪儿?我不明白。