SquirrelMail with Apache

Apache Configuration

  • Directory on an existing webserver
    Edit /usr/local/apache2/conf/httpd.conf to give access to Squirrelmail at http://<yourserver>/squirrelmail:

    Alias /squirrelmail /var/websites/mail/htdocs
    <Directory /var/websites/mail/htdocs>
      Options Indexes
      AllowOverride none
      DirectoryIndex index.php
      Order allow,deny
      allow from all
    </Directory>
  • Virtual Host setup
    Edit /usr/local/apache2/conf/httpd.conf to create a virtual host webmail.example.com:

    <VirtualHost *:80>
      ServerAdmin postmaster@example.com
      DocumentRoot /var/websites/mail/htdocs
      ServerName webmail.example.com

      ErrorLog /var/websites/mail/logs/mail-error_log
      CustomLog /var/websites/mail/logs/mail-access_log combined

      <Directory /var/websites/mail/htdocs>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
      </Directory>
    </VirtualHost>

Securing Webmail
Assuming you've already created an SSL certificate according to the Apache SSL Instructions:
Add a RewriteRule in /usr/local/apache2/conf/extra/httpd-ssl.conf to force clients to connect to the webmail interface through an SSL encrypted session. If you don't want your internal users to be encrypted, adjust the REMOTE_ADDR RewriteCond to reflect your internal network. If you want all IPs encrypted, remove that condition altogether.

  <Directory /usr/local/mail/htdocs>
    RewriteEngine on
#Optional if you don't want a certain IP address range encrypted
    #RewriteCond  %{REMOTE_ADDR} !^192\.168\.0\.[0-9]+$

    RewriteCond %{HTTPS} !=on
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
  </Directory>

Credits

Various bits of code, scripts, and procedures were put together with information from John Simpson's qmail.jms1.net website. It's an excellent resource on managing and setting up a Qmail server.

Recent Updates

  • 2 years 2 days ago
  • 2 years 2 days ago
  • 2 years 4 days ago
    php 8.x
  • 2 years 6 days ago
    10.6.7
  • 2 years 1 week ago
    Drop Centos 5/6 stuff