IMAP & PHP - Fetching all emails from sent and inbox folders

Viewed 14633

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

The hostname I am using is:

$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';

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

How do I grab all emails sent and received?

3 Answers
Related