Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to integrate a webmail system into a website I'm building. I'd basically like a webmail interface built into my existing application.

I need mail to be sent to their usernames and be read in the website. But, I'd also like users to be able to access their mail through IMAP as well. I need the user to authenticate with the mail server with their site credentials.

I know PHP can read IMAP boxes, but I'm under the impression that that's not very efficient for a large-scale multi-user environment. I know some mail daemons can store their boxes and messages in MySQL and authenticate against other systems. I'd imagine that'd be a smoother solution, no?

Any ideas on what systems to look into?

share|improve this question
Why don't you try to customize SquirrelMail insted of reinventing the wheel? – lrosa Dec 6 '10 at 17:15
Use an IMAP server that is smart enough to maintain its index, and does caching (ie Dovecot + maildir) and the concern about IMAP efficience becomes a lot less relevant. – Zoredache Dec 8 '10 at 0:12
up vote 0 down vote accepted

Most mail daemons can authenticate against other backends (MySQL, Postgres, LDAP are most common). If you are using some kind database of for site, just put correct queries in postfix config to authenticate against your site database.
Storing e-mails in database is unefficient because of additional overhead introduced. For most cases, maildir is the way to go.
IMAP handles a lot of things, including mail client concurrency, folders, deletion, authentication - reinventing most of them feels "not right".
I had run webmail for 10 000 clients using roundcube and single box with IMAP (caching imap connection using imapproxy to avoid auth overhead on each request).

share|improve this answer
So, when I want to display mail on the web app, I'd use the PHP IMAP library to read the data, with imapproxy for caching? – Adrian Gonzales Dec 6 '10 at 18:09

Why reinvent the wheel like Irosa said? Look into Google Apps:

You can host all of your email there and never have to worry about server configurations, mail delivery, ports, security, etc. You can use any domain name and can customize the logo/coloring of the page.

share|improve this answer

Please refer the URL with help of which you can integrate your Mail (IMAP) with PHP.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.