PDA

View Full Version : شکل با دریافت ایمیل بواسطه php



esmahdi
دوشنبه 07 دی 1394, 10:48 صبح
سلام
من اسکریپتی به شکل زیر دارم که قصد دارم باهاش ایمیلها رو دریافت کنم:

<?php
header('Content-Type: text/html; charset="UTF-8"');
$mbox = imap_open("{mail.aldaleel-inst.com:143/novalidate-cert}INBOX", "mahdi@aldaleel-inst.com", "sQB42!s4")
or die("can't connect: " . imap_last_error());

$MC = imap_check($mbox);

$result = imap_fetch_overview($mbox,"1:{$MC->Nmsgs}",0);
foreach ($result as $overview){
$body = imap_body($mbox, $overview->msgno);
$body = utf8_decode(imap_utf8($body));
echo $body."<br>";
echo "+++++++++++++++++++++++++++"."<br>";
}
imap_close($mbox);
die();
و نتیجه به شکل زیر چاپ می شود:

------=_Part_2071896_1613472565.1450778285121 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit mahdibody ------=_Part_2071896_1613472565.1450778285121 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
mahdibody
------=_Part_2071896_1613472565.1450778285121--
+++++++++++++++++++++++++++
--047d7bb04ecefac48b0527de34b7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 Ym9keSBnbWFpbCDZhdiq2YYg2KfYtdmE2YoNCg== --047d7bb04ecefac48b0527de34b7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: base64 PGRpdiBkaXI9Imx0ciI+Ym9keSBnbWFpbCDZhdiq2YYg2KfYtd mE2Yo8L2Rpdj4NCg== --047d7bb04ecefac48b0527de34b7--
+++++++++++++++++++++++++++
------=_Part_3611408_1890195242.1451210272328 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 Ym9keSB5bWFpbCDYqNiv2YbZhyDYp9i12YTbjCDYp9uM2YXbjN mE ------=_Part_3611408_1890195242.1451210272328 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
body= ymail =D8=A8=D8=AF=D9=86=D9=87 =D8=A7=D8=B5=D9=84=DB=8C =D8=A7=DB=8C=D9=85= =DB=8C=D9=84
------=_Part_3611408_1890195242.1451210272328--
+++++++++++++++++++++++++++
چی کار باید بکنم که بدنه ایمیل من به درستی نمایش داده بشه.

مهرداد سیف زاده
دوشنبه 07 دی 1394, 10:58 صبح
باید دیکدش کنی
http://stackoverflow.com/questions/15539902/php-imap-decoding-messages