开发者

How do I parse HTML email using PHP IMAP?

开发者 https://www.devze.com 2023-02-11 10:40 出处:网络
I\'m trying to parse HTML data in an email using PHP\'s IMAP functions. When I echo imap_body($Mailbox, 1); by example, the HTMl contained inside seems to be converted into开发者_C百科

I'm trying to parse HTML data in an email using PHP's IMAP functions.

When I echo imap_body($Mailbox, 1); by example, the HTMl contained inside seems to be converted into开发者_C百科 a different encoding (MIME I suspect)

Here is a sample chunk of $body:

<TH=20
      style=3D"PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: =
5px; COLOR: #fff; PADDING-TOP: 5px; BORDER-BOTTOM: #6eafd0 1px solid; =
BACKGROUND-COLOR: #004454"=20
      align=3Dleft>Site</TH>

How do I convert the received the body data into parsable HTML ?

Thank you


Yes, looks old MIMEish. Perhaps try $decoded = quoted_printable_decode ( $body );

The "3D" part is a give away: "US-ASCII equal sign (decimal value 61) must be represented by '=3D'". ( wiki on quoted-printable encoding).

0

精彩评论

暂无评论...
验证码 换一张
取 消