[請益] 收信內文亂碼請教

看板PHP作者 (默默人)時間12年前 (2013/03/20 10:11), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
第一次版上po文 請大家多多指教 以下是全部程式碼 (下方有關於內文程式碼部分的解說) <?php /* connect to gmail */ $hostname = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX'; $username = 'username'; $password = 'userpass'; /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error()); /* grab emails */ $emails = imap_search($inbox,'ALL'); /* if emails are returned, cycle through each... */ if($emails) { /* begin output var */ $output = ''; /* put the newest emails on top */ rsort($emails); /* for every email... */ foreach($emails as $email_number) { /* get information specific to this email */ $overview = imap_fetch_overview($inbox,$email_number,0); $text = utf8_encode(imap_utf8(quoted_printable_decode(imap_fetchbody( $inbox,$email_number,2)))); /* output the email header information */ $output.= '<div class="toggler '.imap_utf8($overview[0]->seen ? 'read' : 'unread').'">'; $output.= '<span class="subject">'.imap_utf8($overview[0]->subject).'</span> '; $output.= '<span class="from">'.imap_utf8($overview[0]->from).'</span>'; $output.= '<span class="date">on '.imap_utf8($overview[0]->date).'</span>'; $output.= '</div>'; /* output the email body */ $output.= '<div class="body" >'.$text.'</div>'; } echo $output; } /* close the connection */ imap_close($inbox); ?> 小弟使用imap_utf8對標題作轉換正常 但是對內文 $text = utf8_encode(imap_utf8(quoted_printable_decode(imap_fetchbody( $inbox,$email_number,2)))); 仍持續出現亂碼 題外話... 原本一直imap_open不到 結果睡了個覺發現沒開imapXD 然後開始測試 結果全部亂碼 然後又跑去睡了個覺 突然靈光乍現跑去看php函式庫 又解決了XD 可是這一次還是想不通... 想請教一下大大們的意見 非常感激 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.169.212.157 ※ 編輯: jackert 來自: 118.169.212.157 (03/20 10:12)

03/20 10:14, , 1F
檔案編碼、來源字串編碼
03/20 10:14, 1F
文章代碼(AID): #1HIHhC5K (PHP)
文章代碼(AID): #1HIHhC5K (PHP)