php imap - get body and make plain text

后端 未结 6 1904
故里飘歌
故里飘歌 2020-12-30 02:18

I am using the PHP imap function to get emails from a POP3 mailbox and insert the data into a MySQL database.

Here is the PHP code:

$inbox = imap_ope         


        
6条回答
  •  时光取名叫无心
    2020-12-30 02:52

    $data = imap_fetchbody($this->imapStream, $Part->uid, $Part->path, FT_UID | FT_PEEK);
    if ($Part->format === 'quoted-printable' && $data) {
        $data = quoted_printable_decode($data);
    }
    

    This is required for mails with

    Content-Transfer-Encoding: quoted-printable

    But for mails with

    Content-Transfer-Encoding: 8bit

    simply imap_fetchbody is enough.

    Above code was taken from a cake-php component created for fetching mails from mail boxes throgh IMAP.

提交回复
热议问题