0
我一直在玩這個,不能把它拉到正確的部分輸入到數據庫中的消息。使用imap_fetchbody不工作的零件號?
當我使用零件編號1或零件編號2時,可以將其插入。但是我也沒有找到。我想拉的HTML,以便我保留我的換行符等。
$emails = imap_search($inbox,'ALL');
/* if emails are returned, cycle through each... */
if($emails) {
foreach($emails as $email_number) {
$overview = imap_fetch_overview($inbox,$email_number,0);
$body = imap_fetchbody($inbox,$email_number,"1");
$subject = $overview[0]->subject;
createEvent($subject, $body, $email_number, $inbox);
}
}
function createEvent($subject, $body, $msgNo, $inbox) { //process the body of the email and take it apart and find stuff in it...do whatever processing you need to here
$customer = '';
$store = '';
$event = '';
$time = time();
$status = '';
// take the subject apart to get the individual elements
$split_subject = explode (":", $subject);
$customer = trim($split_subject[1]);
$store = trim($split_subject[3]);
$event = trim(substr($split_subject[5], 0, 3));
$status = substr($split_subject[5], 4);
$priority = getPriority($event, $status);
$amcs_db = mysqli_connect(AMCS_HOST, AMCS_USER, AMCS_PASS, AMCS_NAME) or die('Cannot connect to database');
$message_body = mysqli_real_escape_string($amcs_db, $body);
$sql = "INSERT into events values (0, '$customer', '$store', '$event', '$status', '$priority', '$time', '$body')";
$result = mysqli_query($amcs_db, $sql) or die("Error writing to AMCS db");
if ($result){ /*delete the email if the insertion was succesful*/
//$delete = imap_delete($inbox, $msgNo);
//imap_expunge($inbox);
}
mysqli_close($amcs_db);
}// end function
當使用零件號1我與沒有換行符純文本,一切看起來正確編碼的權利。當我使用2它現在有斷行但有一些點出現「錯誤: = A0 = A0 = A0 = A0 = A0 = A0 = A0 =符號#1:錯誤符號控制器」。在常規電子郵件中,它的格式是在一行中出現錯誤,然後下一行是縮進。所以這似乎是一種類型的問題,如何將這個縮影放入電子郵件。
我該如何解決這個問題?如果我使用零件號2.2或1.2,它將它輸入到我的數據庫空白中,這不是我想要的,哈哈。
謝謝!