4

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.

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
Kinaan Khan Sherwani
  • 1,504
  • 16
  • 28

1 Answers1

3

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.

Max
  • 10,701
  • 2
  • 24
  • 48
  • Interesting. I'm curious if they have other oddities. Do you have a reference for their implemenation? – bishop Nov 20 '15 at 13:23
  • I'm not sure there's any one place that documents their pop weirdness, but here's recent mode: https://support.google.com/mail/answer/47948?hl=en – Max Nov 20 '15 at 13:35
  • hmm. But the problem is that everyone on the phplist forums seem to recommend using pop. Not a single sole mentioned using IMAP. that's what actually bugging me. – Kinaan Khan Sherwani Nov 20 '15 at 15:43
  • 2
    I have no idea why anyone would prefer POP to IMAP. It literally is less powerful and featureful than IMAP in every way. It is simpler, but that is it's only advantage. – Max Nov 20 '15 at 16:46