Postfix, Courier, Squirrelmail and Spamassassin
From Gentoo Linux Wiki
This guide will show you how to setup a mailserver with webmail and spam detection.
Contents |
[edit] 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.
[edit] Postfix
Edit the following file.
myhostname = hostname.domain.tld mydomain = domain.tld mydestination = /etc/postfix/mydestination
Create the /etc/postfix/mydestination file and put the domains this server accepts mail for. One domain per line.
domain1.tld domain2.tld domain3.tld etc...
Run the following command. Postfix will not work correctly without it.
[edit] Courier Imap
Make sure you have the Use Flags: pam (?) set.
Edit the following files. There will be other stuff in it, just delete it all and replace it with authpam.
authmodulelist="authpam" authmodulelistorig="authpam"
authmodulelist="authpam" authmodulelistorig="authpam"
[edit] 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.
[edit] Apache with PHP
Make sure you have the Use Flags: apache2 (?) 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.
<VirtualHost *:80> DocumentRoot "/path/to/webroot" ServerName domain.tld <Directory "/path/to/webroot"> allow from all Options +Indexes </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.domain.tld Redirect / http://domain.tld/ </VirtualHost>
There will be other stuff in the following file. Just add -D PHP5 to the end of it
APACHE2_OPTS="-D PHP5"
[edit] 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.
[edit] SpamAssassin
Edit the local.cf file. Here are some options to start with.
rewrite_header Subject *****SPAM***** report_safe 0 trusted_networks 127.0.0.1 required_score 5.0 use_bayes 1 bayes_auto_learn 1 dns_available yes
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:
smtp inet n - n - - smtpd -o content_filter=spamassassin
Now at the end of the file add the following (it is all one line):
spamassassin unix - n n - - pipe user=nobody argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
[edit] 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/