imap_fetchbody HTML with strange chars

2019-09-05 02:39发布

问题:

I need to extract the body from an e-mail

code

$body = imap_fetchbody($this->stream, $this->msgno, $section);

But the output contains some strange chars. In the first HTML tag in the first line <div dir=3D"ltr">.. Why the 3D ??

output

<div dir=3D"ltr"><div class=3D"gmail_quote"><br><table width=3D"100%" cells=
pacing=3D"0" cellpadding=3D"0" style=3D"background:#efefef" align=3D"center=
" height=3D"auto"><tbody><tr><td><table border=3D"0" cellspacing=3D"0" cell=
padding=3D"0" width=3D"700" bgcolor=3D"#efefef" align=3D"center" height=3D"=
68"><tbody><tr height=3D"20"><td width=3D"150">=C2=A0</td><td width=3D"548"=
>=C2=A0</td></tr><tr><td height=3D"32" valign=3D"bottom" width=3D"150"><a h=
ref=3D"http://www.aliexpress.com?tracelog=3Drowan&amp;rowan_id1=3DsellerSen=
dGoodsTimeoutMainToBuyer_en_US_2015-12-07&amp;rowan_msg_id=3D64597127548444=
$75498a4ce9274d1888eebf93621499b6&amp;ck=3Din_edm_other" target=3D"_blank">=
<img style=3D"VERTICAL-ALIGN:bottom" border=3D"0" alt=3D"aliexpress.com" sr=
c=3D"http://gtms01.alicdn.com/tps/i1/TB1RvclHFXXXXaQXpXXxT2CGpXX-160-40.png=
" width=3D"160" height=3D"40"></a></td><td style=3D"COLOR:#ccc" height=3D"3=
2" valign=3D"bottom" width=3D"548" align=3D"right"><a style=3D"PADDING-BOTT=
OM:0px;PADDING-LEFT:4px;PADDING-RIGHT:4px;FONT-FAMILY:arial;COLOR:#666;FONT=
-SIZE:11px;TEXT-DECORATION:none;PADDING-TOP:0px" href=3D"http://trade.aliba=
ba.com/order_list.htm?tracelog=3Drowan&amp;rowan_id1=3DsellerSendGoodsTimeo=
utMainToBuyer_en_US_2015-12-07&amp;rowan_msg_id=3D64597127548444$75498a4ce9=
274d1888eebf93621499b6&amp;ck=3Din_edm_other" target=3D"_blank">My Orders</=
a> | <a style=3D"PADDING-BOTTOM:0px;PADDING-LEFT:4px;PADDING-RIGHT:4px;FONT=
-FAMILY:arial;COLOR:#666;FONT-SIZE:11px;TEXT-DECORATION:none;PADDING-TOP:0p=
x" href=3D"http://www.aliexpress.com/help/home.html#center?tracelog=3Drowan=
&amp;rowan_id1=3DsellerSendGoodsTimeoutMainToBuyer_en_US_2015-12-07&amp;row=
...

回答1:

It's quoted-printable text, probably the result of passing through a "dumb" mail client. = is used to encode/escape unprintable/metacharacters, much like &...; is used in HTML.

=3d is the quoted-printable representation of an =: 3d hex = 61 ascii = equals sign.



标签: php email imap