IMAP& PHP-从已发送和收件箱文件夹中获取所有电子邮件

问题描述:

我正在尝试获取所有已接收和发送的电子邮件,并使用PHP将其写入mySQL数据库.

I am trying to fetch any emails received and sent, and write it to the mySQL database using PHP.

我使用的主机名是:

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';

哪个仅引用收件箱,并且成功地仅抓取收到的电子邮件.

Which is referencing just the inbox, and successfully grabs just emails received.

要抓取已发送的电子邮件,我正在尝试使用此主机名:

To grab emails sent, I am trying to use this hostname:

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';

通过将"INBOX"替换为"[Gmail]/所有邮件",没有电子邮件(甚至没有发送)并被退回.

By replacing "INBOX" with "[Gmail]/All Mail", no emails (not even sent) and being returned.

我该如何抓取所有发送和接收的电子邮件?

How do I grab all emails sent and received?

您可能需要在两个呼叫(收件箱和已发送邮件)中执行此操作.根据这篇文章: GMAIL发送的文件夹无法使用IMAP进行访问,已发送邮件文件夹称为[gmail]/sent mail

You probably need to do this in two calls, inbox and sent items. According to this post: GMAIL sent folder not accessible using IMAP, the sent items folder is called [gmail]/sent mail