I am trying to process the bounced emails in phplist using a gmail's email as the bounce back address. When I tried to process bounces, I got stucked in the similar scenario as mentioned in this Post - There are 250 bounces to process.
Phplist was able to fetch only 250 emails from my gmail's account. On further investigating phplists' code I came across this line of code that seems like the culprit.
$num = imap_num_msg($link);
// get only count of 250
Skipping more details. I wrote few lines of code to get the mail count using imap
and pop
. The pop version returns the wrong count whereas that returned by imap version is correct
$username = 'bounceemail@mydomain.com';
$password = 'password';
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$inbox = imap_open($hostname,$username,$password);
$num = imap_num_msg($inbox);
echo $num; // prints 65,051 ( correct one)
$hostname = '{pop.gmail.com:995/pop3/ssl}INBOX';
$inbox = imap_open($hostname,$username,$password);
$num = imap_num_msg($inbox);
echo $num; // prints 250 as count ( wrong one)
I actually need to know why the counts are different for same email with different protocols. Also , All the help I found on internet related to phplist bounce processing explicitly ask to use the {pop.gmail.com:995/pop3/ssl}INBOX
version. So I can't risk using the other version to process bounces.
Gmail has a non standard POP implementation that only exposes 250-300 messages at a time until you download and delete them. Or if you use recent:username as your username, it will show you the last 30 days instead.
Either way, if you want full access to your Gmail account you need to use IMAP.