php - Part number using imap_fetchbody not working? -
i've been playing around , can not pull right part of message inputted database.
i can insert when utilize part number 1 or part number 2. neither looking for. want pull html retain line breaks , such.
$emails = imap_search($inbox,'all'); /* if emails returned, cycle through each... */ if($emails) { foreach($emails $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 body of email , take apart , find stuff in it...do whatever processing need here $customer = ''; $store = ''; $event = ''; $time = time(); $status = ''; // take subject apart 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 database'); $message_body = mysqli_real_escape_string($amcs_db, $body); $sql = "insert events values (0, '$customer', '$store', '$event', '$status', '$priority', '$time', '$body')"; $result = mysqli_query($amcs_db, $sql) or die("error writing amcs db"); if ($result){ /*delete email if insertion succesful*/ //$delete = imap_delete($inbox, $msgno); //imap_expunge($inbox); } mysqli_close($amcs_db); }// end function
when using part number 1 plain text no line breaks , looks correctly , encoded right. when utilize 2 has line breaks has spots "errors: =a0=a0=a0=a0=a0=a0=a0 = sign # 1: error sign controller" showing. in regular email it's formatted errors on 1 line , next line indented. seems type of issue how indention beingness set email.
how can right issue? if utilize part number 2.2 or 1.2 enters db blank , that's not want, lol.
thanks!
i still have not resolved issue using different part numbers figured out solution. if set database using "1", when echo out retains line breaks when utilize nl2br(). hope helps somebody.
i'd still love know why wasn't working though. thanks!
php parsing email encoding imap
No comments:
Post a Comment