postfix + spamassassin - Printable Version +- Linux-Noob Forums (https://www.linux-noob.com/forums) +-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html) +--- Forum: Tips and Tricks (https://www.linux-noob.com/forums/forum-59.html) +--- Thread: postfix + spamassassin (/thread-3851.html) |
postfix + spamassassin - hijinks - 2003-12-24 This is a simple doc on how to get spamassassin and postfix working together. This doc is targeted towards people with Redhat or Fedora. I also use apt-get. If you don't, you are missing out. Grab it at [/url]http://apt.freshrpms.net. I like postfix mainly because its proven itself as being a fast and secure MTA. It is also very simple to configure unlike sendmail. Lets grab the needed rpms using apt-get. Chances are apt-get will prompt you to install other needed rpms, just hit yes and let them install Code: apt-get install postfix spamassassin redhat-switch-mail Now that you have all the needed rpms installed lets make sure sendmail won't start on startup and the SA and postfix will load on startup Code: chkconfig sendmail off Now lets just the switch-mail program to make sure postfix is our default MTA Code: redhat-switch-mail Then select postfix and hit ok. It'll change some symlinks to make sure that postfix is the default MTA. Now we are ready to start to config SA and postfix to end spam for good So we need to create a spam user and also a homer dir for the spam user then make sure all the permissions are ok Code: groupadd spam Now that the spam user is setup we have to make a spamfilter file. This is the file that will run the mail through spamassassin. create a file in /usr/local/bin/spamfilter.sh and insert the following lines into the file Code: #!/bin/sh Now that the file is made we have to set the permissions and ownership for the file so that the user spam can run the file Code: chmod +x /usr/local/bin/spamfilter.sh Now lets setup postfix. edit the file /etc/postfix/main.cf. Below I have copied the lines I have edited in that file just as they appear BEFORE i edited them. Its up to you to change them. If you see a # in front make sure you remove it. If you don't see one then just edit that line. Ignore the () on the line.. they are my notes to you. Code: #myhostname = host.domain.tld (host.domain.com) Thats it for main.cf. Now lets edit the file /etc/postfix/master.cf Below I will show the originals then what you should chanjge it to smtp inet n - y - - smtpd change it to look like this smtp inet n - n - - smtpd -o content_filter=spamfilter:dummy then scroll down to the bottom of the file and add the following. NOTE! the following line should just be one line in the file spamfilter unix - n n - - pipe flags=Rq user=spam argv=/usr/local/bin/spamfilter.sh ${sender} ${recipient} Now you are done with that. So the last thing to do is change how spamassassin is started. Edit the file /etc/sysconfig/spamassassin Code: # Options to spamd The last thing we have to edit is the SA config. It is located at /etc/mail/spamassassin/local.cf. I have an example one at www.zcentric.com/local.cf or use [url=http://www.yrex.com/spam/spamconfig.php]http://www.yrex.com/spam/spamconfig.php to generate your own. Once you have created your own local.cf file you can move on to the next step Now lets startup SA and postfix and do some testing! Code: service spamassassin start Then test it out. Make sure you send mail from an outside host. SA does not seem to process it if you send it from the same host that the mailserver is running. You should see something like this in the headers Code: X-Spam-Status: No, hits=1.1 required=7.0 As you can see I have my limit set at 7 and my test mail got a 1.1 rating. So it doesn't get marked as spam. If its above 7.0 then it'll change the subject to ****SPAM**** before the real subject. Then I have a filter setup on my mailclient to move all mails with that in the subject to a spam folder. You can make SA delete all spam also. Read the SA docs and its all done in the local.cf file ANother great tip from the J to the Y. Damn i rule |