从PHP访问Gmails SPAM文件夹

时间:2013-01-16 23:01:49

标签: php gmail imap spam

如何使用PHP从Gmail帐户访问SPAM文件夹?这是我连接到gmails imap服务器的代码。当我用垃圾邮件替换INBOX时会导致异常:

$mailbox = imap_open("{imap.googlemail.com:993/ssl}INBOX", "USERNAME@googlemail.com", "PASSWORD");
$mail = imap_search($mailbox, "ALL");
$mail_headers = imap_headerinfo($mailbox, $mail[0]);
$subject = $mail_headers->subject;
$from = $mail_headers->fromaddress;
imap_close($mailbox);

1 个答案:

答案 0 :(得分:3)

this post起,文件夹名称似乎为[Google Mail]/Spam[Gmail]/Spam