|
|
In this guide I'll walk you through getting a webmail client running on your server. In order to do this we'll be using three major tools: PostFix, Dovecot, and SquirrelMail. We'll start with Postfix. PostFix Postfix is a mail transfer agent, in fact it's the default mail transfer agent for Ubuntu, which is what we're working with. To install Postfix with SMTP-AUTH and TLS capabilities open up the Terminal and issue the following command: apt-get install postfix libsasl2 sasl2-bin libsasl2-modules libdb3-util procmail Now that Postfix is installed all you have to do is configure it. To do this, first go back to the Terminal and type this command: dpkg-reconfigure postfix You will now be prompted with several questions and options to configure PostFix. Here's the default settings that are a good place to start:
Now that your installation is configured, you have a long list of commands that need to be run via the terminal. To find a well formatted list of the commands, visit this link and scroll down to the text that says The run the following commands and enter everything up until the Authentication section, which I will now cover. In order to authenticate with Postfix we will use saslauthd. We have to change a few things to make it work properly. Because Postfix runs chrooted in /var/spool/postfix we have change a couple paths to live in the false root. (ie. /var/run/saslauthd becomes /var/spool/postfix/var/run/saslauthd): First we edit /etc/default/saslauthd in order to activate saslauthd. Remove # in front of START=yes and add the PWDIR, PARAMS, and PIDFILE lines: # This needs to be uncommented before saslauthd will be run automatically START=yes PWDIR="/var/spool/postfix/var/run/saslauthd" PARAMS="-m ${PWDIR}" PIDFILE="${PWDIR}/saslauthd.pid" # You must specify the authentication mechanisms you wish to use. # This defaults to "pam" for PAM support, but may also include # "shadow" or "sasldb", like this: # MECHANISMS="pam shadow" MECHANISMS="pam" Note: If you prefer, you can use "shadow" instead of "pam". This will use MD5 hashed password transfer and is perfectly secure. The username and password needed to authenticate will be those of the users on the system you are using on the server. Next, we update the dpkg "state" of /var/spool/portfix/var/run/saslauthd. The saslauthd init script uses this setting to create the missing directory with the appropriate permissions and ownership: dpkg-statoverride --force --update --add root sasl 755 /var/spool/postfix/var/run/saslauthd Finally, start saslauthd: /etc/init.d/saslauthd start Now we can test to make sure everything is working properly. To see if SMTP-AUTH and TLS work properly now run the following command in the terminal: telnet localhost 25 After you have established the connection to your postfix mail server, type the following: ehlo localhost If you see these two lines (as well as others): 250-STARTTLS 250-AUTH Then everything is working. You can now type quit to return to the shell. Dovecot The next thing you need to install is Dovecot, our primary mail delivery agent. Begin by installing the following packages: dovecot-common dovecot-imapd dovecot-pop3d Now that Dovecot is installed all you have to do is configure it. First you need to decide which mail protocol you will use. POP3 is good if you want to download your email and then view it, but IMAP is nice if you want to be able to check your email from multiple machines pretty much anywhere. For this installation let's do IMAP. The first thing you need to do is set the protocols in the /etc/dovecot/dovecot.conf file. Do this by adding the following line: protocols = pop3 pop3s imap imaps Now those protocols will be started when Dovecot starts. Note that you could just install the IMAP protocols if you wanted. Next add this line in the POP3 section: pop3_uidl_format = %08Xu%08Xv Your next choice will be which type of mailbox you'll want to use. There are two types to choose from: maildir and mbox. Let's choose mbox for this installation since it works with Postfix the best. To configure Dovecot to use maildir we need to edit the /etc/dovecot/dovecot.conf file by adding the following line: default_mail_env = mbox:~/mail:INBOX=/var/mail/%u Now you're ready to start and test Dovecot. Open up the terminal and type: /etc/init.d/dovecot start To make sure it's running use this command: -A|grep dovecot If you've gotten this far, Dovecot is working but may still have to be configured so that users can login to check their mail. The simplest login method is sending the user login info in plain text and allowing access only to users that already have UNIX access (ie. in /etc/passwd) to the machine Dovecot is running on. Allowing access only to users that already have UNIX access is the Dovecot default, nothing has to be done to configure this. And, plain text logins are enabled by default when using secure protocols. To enable plain text logins when not using a secure protocol, put the following line in /etc/dovecot/dovecot.conf: disable_plaintext_auth = no If you are using the secure protocols imaps or pop3s, plain text logins is not a problem, because the transfer is done via an encrypted connection. If you are using simply imap or pop3, and will be connecting to the server from outside your local computer or home network, it is a good idea to configure more secure authentication. For further details about how to do this, see [WWW] this page on the dovecot website. The final step is to get Dovecot working with SSL for security's sake. To do this you need to edit /etc/dovecot/dovecot.conf and add these lines: ssl_cert_file = /etc/ssl/certs/dovecot.pem ssl_key_file = /etc/ssl/private/dovecot.pem ssl_disable = no disable_plaintext_auth = no. Dovecot is set to go now, so we can finally move onto the final step of getting Webmail running: Installing SquirrelMail. SquirrelMail To install SquirrelMail you need to fire up Synaptic and install the squirrelmail package. With SquirrelMail installed we need to move onto configuration. Fortunately, this is very easy with SquirrelMail because it has its own configuration menu. To run it, open the Terminal and type the following command: sudo squirrelmail-configure There are many options here but it would be a smart thing to only edit the ones that are necessary. For the most part the default settings work well, but here are two that you should probably set from the get-go: A. Update IMAP Settings : localhost:143 (other) B. Update SMTP Settings : localhost:25 Also, in menu 4 there's an option for server-side scrolling. You should enable this now as well. Next we need to configure Apache to work with SquirrelMail. Another benefit of using SquirrelMail is that it comes with a sample Apache configuration file that can be easily edited to suit your webmail installation. Copy this file (which is located in /etc/squirrelmail/apache.conf) to /etc/apache2/sites-available/squirrelmail with this command: sudo cp /etc/squirrelmail/apache.conf /etc/apache2/sites-available/squirrelmail Next link the sites-enabled directory with this command: sudo ln -s /etc/apache2/sites-available/squirrelmail /etc/apache2/sites-enabled/squirrelmail Now you should be finished! Just restart Apache: sudo /etc/init.d/apache2 restart And you're done! Open a webbrowser, and go to the address http://localhost/squirrelmail. Change localhost for the address of your server, or your virtualhost, if you have used that Apache setup. You should see the Squirrelmail login box! |