简体   繁体   English

如何使用php imap获取电子邮件的每个主题?

[英]How to get every subject of email with php imap?

<?php
$hostname = '{imap.gmail.com:993/imap/ssl}';
$username = 'xxx@gmail.com';
$password = 'pass';
$inbox = imap_open($hostname,$username,$password);
$nums=imap_num_msg($inbox);
echo  $nums;
for ($i=1;$i<=$nums;$i++){
    $headers = imap_fetchheader($inbox, $i);
    echo  $headers ;}
imap_close($inboxi);
?>

With this code I can get the number of all emails in my gmail box. 使用此代码,我可以在Gmail框中获取所有电子邮件的数量。 But it can't print every subject of email in header info. 但是它不能在标题信息中打印电子邮件的每个主题。 How to get it? 如何获得?

imap_headerinfo()imap_header()将帮助您了解每封电子邮件的主题

This is what I do: 这是我的工作:

$overview = imap_fetch_overview($inbox, $i, 0);
echo $overview[0]->subject . "<BR>";

I think it is easier than using imap_fetchheader. 我认为这比使用imap_fetchheader容易。

Also, you have an extra 'i' in the last $inbox . 另外,最后一个$ inbox中还有一个额外的“ i”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM