Some times I have problem accessing Gmail because of some Firewall restrictions. Or I would like to have my own WebMail client for my mail service hosted with Google Apps. I tried several setting and I found out that it is not that difficult just you have to know the right parameters.
Here are the parameters that worked for me:
In your main.inc.php try to modify these setting:
// IMAP settings
$rcmail_config['default_host'] = 'ssl://imap.gmail.com:993';
$rcmail_config['default_port'] = 993;
$rcmail_config['imap_auth_type'] = null;
$rcmail_config['username_domain'] = 'gmail.com';
$rcmail_config['mail_domain'] = 'gmail.com';
//SMTP settings
$rcmail_config['smtp_server'] = 'ssl://smtp.gmail.com';
$rcmail_config['smtp_port'] = 465;
$rcmail_config['smtp_user'] = '%u';
$rcmail_config['smtp_pass'] = '%p';
//MBox settings
$rcmail_config['drafts_mbox'] = '[Gmail]/Drafts';
$rcmail_config['junk_mbox'] = '[Gmail]/Spam';
$rcmail_config['sent_mbox'] = '';
$rcmail_config['trash_mbox'] = '';
$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash');
[ad#AdBrite inline]
If you want to try. I made this setting on my sub domain mygmail.kristou.com. It is a RoudCube with the above settings.