<?php
$hostname = '{imap.gmail.com:993/imap/ssl}';
$username = 'xxx@gmail.com';
$password = 'pass';
$inbox = imap_open($hostname,$username,$password);
$nums=imap_num_msg($inbox);
echo $nums;
for ($i=1;$i<=$nums;$i++){
$headers = imap_fetchheader($inbox, $i);
echo $headers ;}
imap_close($inboxi);
?>
With this code I can get the number of all emails in my gmail box. But it can't print every subject of email in header info. How to get it?
This is what I do:
$overview = imap_fetch_overview($inbox, $i, 0);
echo $overview[0]->subject . "<BR>";
I think it is easier than using imap_fetchheader.
Also, you have an extra 'i' in the last $inbox .