我想顯示電子郵件的正文內容。我曾嘗試在PHP中使用IMAP,但有些事情是非常錯誤的。 IMAP沒有提供我的信息的正文。它只是拿起身上的簽名。因此,我正在尋找將電子郵件正文內容讀取到網頁的其他方法。如何顯示電子郵件的內容到網站?
這裏是我的電子郵件的原始文件:
免責聲明/版權模糊正在被顯示IMAP,但沒有在身體其他抓起。任何人都可以選擇從Gmail或任何其他可以將內容顯示到網頁的網站閱讀電子郵件?
我已經放棄了使IMAP讀它,因爲沒有人能弄清楚這個問題......我花了幾個小時,所以我放棄了,但這裏是代碼...
<?php
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = '[email protected]';
$password = 'password';
/* 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);
$message = imap_fetchbody($inbox, $email_number, 2);
echo $message;
echo imap_qprint($message);
$message = imap_qprint($message);
echo imap_8bit ($message);
$DateFormatted = str_replace("-0500", "", $overview[0] -> date);
/* output the email header information */
$output .= $overview[0] -> subject ;
$output .= $DateFormatted ;
//$bodyFormatted = preg_replace("/This e-mail(.*)/","",$message);
//$bodyFormatted = preg_replace("/Ce courriel(.*)/","",$bodyFormatted);
/* output the email body */
$output .= $message;
}
echo $output;
}
/* close the connection */
imap_close($inbox);
?>
你可以發佈你試圖獲取消息的'IMAP'代碼嗎? – Cyclonecode