[英]MIME error- accepting MIME types while sending a email
以下腳本可以(幾乎)按我的意願工作。 這個項目是如此接近完成,只有一個小問題。 在電子郵件中,我得到以下信息:“如果可以看到此MIME,則您的客戶端不接受MIME類型!--jacquie1003”
這是通過Novell GroupWise發送的。 我已經包括了郵件腳本和生成的電子郵件。 電子郵件附帶附件,除該錯誤消息外,其他所有內容似乎都不錯。 請參閱下面的消息正文。
用戶正在填寫大約95個字段的表單。 當他們提交驗證時,必須在必填字段上進行。 如果一切都完成了,則在同一窗口中將完成的表單顯示給他們,創建文件,然后創建電子郵件並將電子郵件(以創建的文件作為附件)發送到五個預設收件人組之一。
我的郵件腳本中做錯了什么。 任何幫助將不勝感激。 在這一點上,除非絕對必要,否則我不打算使用PEAR,PHPmailer,Zend等。
對於剪切和粘貼的某些格式,我事先表示歉意。 先感謝您
郵件腳本的開頭
<pre>$head_division = $_POST['head_division'];
$category = $_POST['category'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$FilePath = "c:\\temp\\resumes\\";
$FileName = $officer_pr . "_" . $inc_number . ".html";
$ResumeFile = $FilePath . $FileName;
$to = $fname . "." . $lname . "@tucsonaz.gov";
$from = $fname . "." . $lname;
$subject = $head_division . " Divsional Resume (Test)";
$bound_text = "jacquie1003";
$bound = "--".$bound_text."\r\n";
$bound_last = "--".$bound_text."--\r\n";
$header ="From: " . $from . "@tucsonaz.gov" . "\r\n";
$header .="MIME-Version: 1.0\r\n";
$header .="Content-Type: multipart/mixed; boundary=\"$bound_text\"";
$message = "If you can see this MIME then your client doesn't accept MIME types!\r\n"
.nl2br($message)
.$bound;
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
."Content-Transfer-Encoding: 7bit\r\n\r\n"
."Please see the attached resume file.<br /><br />"
."<strong><u>Incident Summary</u></strong><br />"
."<strong>Case Number:</strong> " . $inc_number . "<br />"
."<strong>Category:</strong> " . $category . "<br />"
."<strong>UCR:</strong> " . $ucr . "<br />"
."<strong>Location:</strong> " . $inc_street . "<br />"
."<strong>Date:</strong> " . $inc_date . "<br />"
."<strong>Time:</strong> " . $inc_time . "<br />"
."<strong>Officer:</strong> " . $officer . " / " . $officer_pr . "<br />"
.nl2br($message)
.$bound;
$file = file_get_contents($ResumeFile);
$message .= "Content-Type: text/html; name=" . $FileName . "\r\n"
."Content-Transfer-Encoding: base64\r\n"
."Content-disposition: attachment; file=" . $ResumeFile . "\r\n"
."\r\n"
.chunk_split(base64_encode($file))
.$bound_last;
mail($to, $subject, $message, $header);
</pre>
結束郵件腳本
電郵訊息
請參閱附件的簡歷文件。
事件摘要
案例編號:0910071139
類別:關注的COT事項
UCR:04.03
地點:1310 W. Miracle Mile
日期:10-07-09
時間:1505
總監:史密斯/ 13785
如果您可以看到此MIME,則您的客戶端不接受MIME類型!
--jacquie1003
電子郵件結尾
嘗試使\\ r \\ n脫離邊界。 不確定是否會有所幫助,但是我遇到了類似的問題,添加時它會打印附件的一部分。
在我看來,一個問題是您在郵件中使用了nl2br來換行。 它將在邊界,內容類型等中插入中斷標簽。
也許這樣做會更容易使換行正確:
$header .= "Content...";
$file = file_get_contents($ResumeFile);
ob_start(); //buffer the output rather than send to client
?>
If you can see this MIME then your client doesn't accept MIME types!
<?php echo $bound;?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Please see the attached resume file.<br>
<br>
Incident Summary<br>
<br>
Case Number: <?php echo $inc_number;?><br>
Category: <?php echo $category;?><br>
UCR: <?php echo $ucr;?><br>
Location: <?php echo $inc_street;?><br>
Date: <?php echo $inc_date;?><br>
Time: <?php echo $inc_time;?><br>
Officer: <?php echo $officer;?> / <?php echo $officer_pr;?><br>
<?php echo $bound;?>
Content-Type: text/html; name=<?php echo $FileName;?>
Content-Transfer-Encoding: base64
Content-disposition: attachment; file=<?php echo $ResumeFile;?>
<?php echo chunk_split(base64_encode($file));?>
<?php echo $bound_last;?>
<?php
$message = ob_get_flush();
您可能還必須同時使用multipart / mixed和multipart / alternative,如本教程所示: Web備忘單
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.