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,它将它输入到我的数据库空白中,这不是我想要的,哈哈。
谢谢!