$subjet = $mail->imapUtf8($headinfo['subject']); $encode = mb_detect_encoding($subjet, array("ASCII", 'UTF-8', 'GB2312', "GBK", 'BIG5', 'ISO-8859-1')); if ($encode != 'UTF-8') { $subjet = mb_convert_encoding($subjet, 'UTF-8'); } $from = $headinfo['from']; $fromName = $mail->imapUtf8($headinfo['fromName']); $fromName = mb_convert_encoding($fromName, 'utf8'); $to = empty($headinfo['to']) ? $ac['gmail'] : $headinfo['to']; $toName = empty($headinfo['toName']) ? $ac['amazon_account'] : $headinfo['toName']; $sendtime = $headinfo['date']; $body = $mail->getBody($msgno); $pushtime = date('Y-m-d H:i:s'); $fname = $toName . $message_id . '.html'; $amazon_account = $account_obj->getAmazonAccountByGmail($to); $catrules = $msgcat_obj->getCatRules($to); //分类id和其规则 $classid = 0; imap_clearflag_full($connect, $uids[$i], '\\Seen', ST_UID); //分配邮件进入各个分类 foreach ($catrules as $ct) { $rules_arr = preg_split('/,/', $ct['rules']); if (in_array(substr($from, 0, 1), $rules_arr)) { $classid = $ct['id']; echo "找到了合适的分类\r\n"; continue; } } echo $headinfo['date'] . "\n"; //发件人首字符对应不到分类 if ($classid == 0) {