我正在尝试发送包含多个附件的电子邮件。
这是一个例子:
$uid = md5(uniqid(time()));
$header = "From: Test <test@test.com>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"" . $uid . "\"\r\n\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 .= "Test Email\r\n\r\n";
$header .= "--" . $uid . "\r\n";
$header .= "Content-Type: text/x-csv; name=\"1.csv\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"1.csv\"\r\n\r\n";
$header .= $csvfile1 . "\r\n\r\n";
$header .= "--" . $uid . "--";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= "Test Email\r\n\r\n";
$header .= "--" . $uid . "\r\n";
$header .= "Content-Type: text/x-csv; name=\"2.csv\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"2.csv\"\r\n\r\n";
$header .= $csvfile2 . "\r\n\r\n";
$header .= "--" . $uid . "--";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= "Test Email\r\n\r\n";
$header .= "--" . $uid . "\r\n";
$header .= "Content-Type: text/x-csv; name=\"3.csv\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"3.csv\"\r\n\r\n";
$header .= $csvfile3 . "\r\n\r\n";
$header .= "--" . $uid . "--";
我在csv文件的末尾有一些奇怪的字符,如下所示:
w־סֽד·ֽסמ׳fק־ןo,
‰z{©}ךֺxn+¢”j״¶'Eט²¶*Jײֻrֵz°¶+·$j״¶'5ל†·u+¶+‰ֻ{²װj״¶',
可能是什么问题?
感谢。
答案 0 :(得分:1)
一些问题:
Content-Transfer-Encoding
之前有两个地方需要换行。正如El Yobo在评论中所说,也许你应该尝试使用一个库。