Postfix, Courier, Squirrelmail and Spamassassin

This guide will show you how to setup a mailserver with webmail and spam detection.

Maildirs
In order to create maildir's automatically when you create a new user run the following command.

To create a maildir for users that already exist run the following command as that user.

Postfix
Edit the following file.

Create the /etc/postfix/mydestination file and put the domains this server accepts mail for. One domain per line.

Run the following command. Postfix will not work correctly without it.

Courier Imap
Make sure you have the set.

Edit the following files. There will be other stuff in authmodulelist and authmodulelistorig, just delete it all and replace it with authpam.

Bind
You will need to configure Bind with your DNS information so your domain works. I use Webmin (which is a web based admininstration script) to configure Bind. If you choose this method...

You can now login to webmin at https://192.168.0.1:10000 or https://127.0.0.1:10000 depending on how your accessing it.

You need Apache and PHP installed and configured in order to use squirrelmail.

Apache with PHP
Make sure you have the set.

The following Apache2 configuation will allow you to visit domain.tld and if you type www.domain.tld it will redirect you to domain.tld. Edit the following files.

There will be other stuff in the following file. Just add -D PHP5 to the end of it

Squirrelmail
Squirrelmail is a web based mail client

Copy /var/www/localhost/squirrelmail into your webroot.

Go to "Server Settings" and change your domain name. Select "A" and change your IMAP settings so your IMAP Server is courier.

SpamAssassin
Edit the local.cf file. Here are some options to start with.

If too many messages which are not spam are being tagged as spam, increase "required_score"

Now we need to configure Postfix to use SpamAssassin. Append "-o content_filter=spamassassin" in the /etc/postfix/master.cf file so the first line looks like this:

Now at the end of the file add the following (it is all one line):

Then you have to run:

Services
Start up all the services...

You may want to configure these services to start at boot

That's it, you should now have a mail server up and running for your domain. You can access your Squirrelmail installation at http://domain.tld/squirrelmail/