Use this to get all mail:
$server = '{imap.gmail.com:993/ssl}[Gmail]/All Mail';
We went round and round on this awhile; see here:
https://stackoverflow.com/a/8178514/776695
As stated here, use imap_list
to see which individual folders are available