如何解决从 IMAP 获取“特定”电子邮件信息
为了工作,我每天都会收到 Gmail 电子邮件,其中包含文本,然后是一个列出 URL 的 div 字段,我只想打印这些 URL,而不是整个邮件、我的代码和这个:
<?
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBox';
$username = 'email';
$password = 'pass';
/* try to connect */
$inBox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
/* grab emails */
$emails = imap_search($inBox,'UNSEEN');
/* 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,1.2);
$message = imap_fetchbody($inBox,1);
$message=imap_base64($message);
/* output the email header information */
/*$output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';*/
/*$output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
$output.= '<span class="from">'.$overview[0]->from.'</span>';*/
/*$output.= '<span class="date">on '.$overview[0]->subject.'</span>';*/
/*$output.= '</div>';*/
/* output the email body */
$output.= '<div class="body">'.$message.'</div> <br>';
}
echo $output;
}
/* close the connection */
imap_close($inBox);
?>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。