Friends,

I am listing steps required for setting up SquirrelMail to work with Gmail IMAP. This is especially useful when you like SquirrelMail or don’t have access to regular http://mail.google.com :-) You can even use it to brand your custom domain hosted at Google Apps and seamlessly integrate it your portal (if you can afford, consider buying Google’s Premium Edition which comes with API access at $50/user/year).

Steps:

Create a place holder for SquirrelMail and unpack the latest distribution

mkdir -p /home/squirrel/data/attachments
cd /home/squirrel/
chown -R apache.apache data
tar zxvf ~/downloads/squirrelmail-1.4.13.tar.gz

Configure the installation (do nothing simply save and quit).

cd squirrelmail-1.4.13
./configure

Append following lines into /home/squirrel/squirrelmail-1.4.13/config/config_local.php

$domain = ‘gmail.com’;
// IMAP settings
$imapServerAddress = ‘imap.gmail.com’;
$imapPort = 993;
$use_imap_tls = true;
$imap_auth_mech = ‘login’;
// SMTP settings
$smtpServerAddress = ’smtp.gmail.com’;
$smtpPort = 465;
$use_smtp_tls = true;
$smtp_auth_mech = ‘login’;
// Special folder setting
$trash_folder = ‘[Gmail]/Trash’;
$sent_folder = ‘[Gmail]/Sent Mail’;
$draft_folder = ‘[Gmail]/Drafts’;
// Attachment
$data_dir = ‘/home/squirrel/data/’;
$attachment_dir = ‘/home/squirrel/data/attachments/’;
// Optional -
$provider_name = ‘Gmail alternative by Sudhaker’;
$provider_uri = ‘http://sudhaker.com/’;

Create an alias in apache /etc/httpd/conf.d/squirrel.conf

Alias /sq “/home/squirrel/squirrelmail-1.4.13″
<Directory “/home/squirrel/squirrelmail-1.4.13″>
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>

Verify the setup by browsing to ${site_url}/sq/

User Id: example@gmail.com (or user@example.com)
Password: email_password

Please make appropriate changes for cPanel based hosting (shared hosting).

Please follow following step if SELinux is enabled.

[root@centos ~]# setsebool httpd_can_network_connect true

Please drop a comment if you find it useful.

Cheers,
Sudhaker

Posted Tuesday, February 26th, 2008 at 9:25 am
Filed Under Category: Linux World, Techie Talks, Web Development
You can skip to the end and leave a response. Pinging is currently not allowed.

9

Responses to “Gmail IMAP with SquirrelMail”

Sam Carrara

I have the first part setup, but when it comes to:
Create an alias in apache /etc/httpd/conf.d/squirrel.conf

Alias /sq “/home/squirrel/squirrelmail-1.4.13″

AllowOverride AuthConfig
Order allow,deny
Allow from all

I don’t know what to do there. I have setup what I can and get the response:
Error connecting to IMAP server: tls://imap.gmail.com.
111 : Connection refused

I made sure to allow pop & imap in the Gmail settings.

Thanks for your help,
Sam

Webmaster

I guess you are becoming victim of SELinux ; It can be very frustrating to debug problems related to this (if you are not looking at right log files).

Try executing “id -Z” and find if selinux is enabled. By default “apache” with selinux is not able to make outgoing socket connection (and read anything outside webroot).

Hope this helps.

Cheers,

Ste

Hey Sudhaker,
tx for the tutorial but I was unsuccessful so far.

SquirrelMail version 1.4.13
I keep getting:
Error connecting to IMAP server: tls://imap.gmail.com.
13 : Permission denied

Now, I suspect that gmail is expecting ssl instead of tls protocol; but than, tls works for you…

Any ideas? I checked my credentials million times and I can get in using thunderbird.

Webmaster

Did you check my last comment about SELinux? I usually disable SELinux on my boxes as it is more pain than help.

I assume that you are trying it on your home linux. If so try followings

@ Desktop > System Settings > Security Level > SELinux > httpd > HTTPD

Scripts to connect to the network [allow it]

or if you prefer command line

[root@centos ~]# setsebool httpd_can_network_connect true

Hope this help.

Thanks,

Andrew

I followed the directions given above on a Mac. I was able to get to the login page. However, when I attempt to log in with my gmail username and password, it processes for a while and then Squirrel gives me an error. It says that it the IMAP connection has been dropped. Any ideas?

Webmaster

Never owned a MAC so can’t help you much.

But I assume that MAC is Unix with nice UI and problem is because of SELinux / firewall settings.

Try these things and let me know if you see anything relevant :-

[root@centos ~]# tail /var/log/messages

[root@centos ~]# getsebool -a
And watch for httpd_can_network_connect

Hope this helps.

Andrew

This is on a Mac that does not use SELinux. The error I get also makes it sound like Squirrel was able to make the network connection, but it is being dropped.

I have squirrel working with a local IMAP client, so I don’t believe it is the same error as others were having.

Andrew

Sorry, I saw your other post and replied to it. I’ve tailed the messages and really do no see anything relevant.

BTW, Mac is BSD based, so your description is pretty accurate. I’ll take a look around the net and see if I can find anything related. If I find anything I’ll post a follow-up.

It could be that the connection is timing out. I’ve got a pretty large Gmail inbox right now. I’m going to try archiving everything and see if that will help it through.

ram

I have followed the direction in windows machine but it thrown error like,
Error connecting to IMAP server: tls://imap.gmail.com.
10060 : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

please reply..

Leave a Reply