1 AUTHOR: Jim Gifford <lfs-hints at jg555.com>
5 LICENSE: GNU Free Documentation License Version 1.2
7 SYNOPSIS: How to setup the Extra Capabilities in Courier
9 DESCRIPTION: This hint will show you how to use feature of the Courier Mail
10 Server that are not mentioned in BLFS
12 PREREQUISITES: Courier, Mgetty, Virus Scanner
18 Courier Maillist List Manager
20 This will show you the process on how to setup Courier's Mailing List.
22 Step One : Define the location for the mailling list
23 couriermlm create {directory} {email_address}
24 Example : couriermlm create /home/test-list ADDRESS=testlist@example.com
26 Step Two : Create a user entry for this user.
27 Method A : Add a user to passwd with the home directory the same as create directory above
28 Example : echo "testlist:x:9999:9999:Test Maillist:/home/testlist:/bin/bash" >> /etc/passwd
31 Method B : Add a user to virutal suers with the home directory the same as created directory above
32 Example : mysql -ucourier -p{password} courier-mail
33 insert into users values ('testlist@example.com','','password',
34 'Test Maillist',9999 ,9999,
35 '/home/test-list','');
37 Step Three : Create .courier in the {directory} with the following information
38 | couriermlm msg {directory}
39 Example : couriermlm msg /home/test-list
41 Step Four : Create .courier-default in the {directory} with the following information
42 | couriermlm ctlmsg {directory}
43 Example : couriermlm ctlmsg /home/test-list
45 Step Five : Create .courier-owner in the {directory} with the following information
46 owner_of_list@example.com
47 Example : listmanager@example.com
49 Step Six : Create a cron entry that runs every hour with the following information
50 couriermlm hourly {directory}
51 Example : couriermlm hourly /home/test-list
53 Step Seven : Create a cron entry that runs once a day with the following information
54 couriermlm daily {directory}
55 Example : couriermlm daily /home/test-list
58 You have now created a maillist list under courier. Now you can send a message to your mailist to subscribe
59 Example : testlist-subscribe@example.com
65 Prerequisites: A Virus Scanner
67 This will show you how to setup Amavis(Mail Virus Scanner) to work with Courier.
69 Before you can install Amavis, you will need to install a virus scanner. The one
70 I have been using is Clamav.
72 Download location (HTTP):
73 http://osdn.dl.sourceforge.net/sourceforge/clamav/clamav-0.67.tar.gz
75 Installation of Clamav
77 ./configure --prefix=/usr \
78 --sysconfdir=/etc/clamav
82 Now for the installation of Amavis
84 Download location (HTTP):
85 http://osdn.dl.sourceforge.net/sourceforge/amavis/amavis-0.3.12.tar.gz
88 http://ftp.jg555.com/patches/amavis/amavis-0.3.12-courier-2.patch
89 http://ftp.jg555.com/patches/amavis/amavis-0.3.12-maildrop-securityhole-1.patch
91 Step One - Install Amavis required perl modules
93 perl -MCPAN -e 'install IO::String'
94 perl -MCPAN -e 'install Unix::Syslog'
95 perl -MCPAN -e 'install Convert::UUlib'
96 perl -MCPAN -e 'install Convert::TNEF'
97 perl -MCPAN -e 'install Compress::Zlib'
98 perl -MCPAN -e 'install Archive::Tar'
99 perl -MCPAN -e 'install Archive::Zip'
100 perl -MCPAN -e 'install Mail::Address'
101 perl -MCPAN -e 'install MIME::Tools'
102 perl -MCPAN -e 'install libnet'
104 Step Two - Create Amavis Executable
107 ./configure --prefix=/usr \
110 --with-syslog-level=mail.info \
111 --with-amavisuser=amavis
114 Step Three - Configure Courier
116 In /etc/courier/courierd
118 Change the DEFAULTDELIVERY=./Maildir to DEFAULTDELIVERY="| /usr/bin/maildrop"
122 In /etc/courier/maildroprc
137 FROM="unknown@example.com"
140 if ($RECIPIENT ne "")
142 TO=escape($RECIPIENT)
146 TO="unknown@jg555.com"
149 xfilter "/usr/sbin/amavis $SENDER $RECIPIENT"
151 # Drop anything listed as a Virus into .Virus
153 if (/^Subject:.*VIRUS FROM*/)
154 to "$DEFAULT/.Virus/"
156 # Drop anything listed as a Virus into .Virus
158 if (/^Subject:.*VIRUS TO*/)
159 to "$DEFAULT/.Virus/"
163 Create the same information as above only as .mailfilter in the users
168 Mailing List Filtering
170 This will show you how to filter Mailing Lists that you subscribe to into different
175 Go to the Maildir in the users home directory. maildirmake .{list_name}.
177 Example : maildirmake .lfs-dev
181 Make sure the newly created .{listname} has the proper user permission.
182 chown {user:user} .{listname} -R
184 Example chown jim:jim .lfs-dev -R
188 Edit .mailfilter in the users home directory. Add the following information to
193 if (/^List-Post:.*{list_address@*/)
194 to "$DEFAULT/.{list_name}/"
196 You will have to view the headers of the mail from the list server to find a
197 match criteria you can use. List-Post,list-post,List-ID, and To are the most common
198 match cirteria's to use.
202 if (/^List-Id:.*lfs-dev.linuxfromscratch.org*/)
203 to "$DEFAULT/.lfs-dev/"
209 This will show you how to setup Faxing within Courier.
211 Step One - If mgetty is not installed, follow the mgetty hint.
212 Hint Link : http://www.linuxfromscratch.org/hints/downloads/files/mgetty.txt
214 Step Two - Locate Faxq-helper
216 Find Mgetty's faxq-helper program and Change into the directory that it is
219 How to Locate : find / -name faxq-helper
220 Sample Output : /usr/lib/mgetty+sendfax/faxq-helper
221 Sample cd : cd /usr/lib/mgetty+sendfax
223 Step Three - Create a symlink for new_fax
225 ln -sf /usr/share/courier/new_fax
229 Send an email to {phone_number}@fax, this will fax to the phone number specified.
231 Note: This does not work with Outlook Express
237 This will show you how to use the Courier::Filter framework with Courier.
239 Step One - Install Courier Filter required perl modules
241 perl -MCPAN -e 'install Net::RBLClient'
242 perl -MCPAN -e 'install Digest::MD5'
243 perl -MCPAN -e 'install MIME::Tools'
244 perl -MCPAN -e 'install Mail::SPF::Query'
246 Step Two - Install Courier Filter
248 perl -MCPAN -e 'install Courier::Filter'
250 Step Three - Create pureperlfilter.conf
252 You can retrieve a sample perlpurefilter.conf from
254 http://www.linuxfromscratch.org/hints/downloads/attachments/courier-extras/pureperlfilter.conf
256 Step Four - Edit /usr/lib/perl5/site_perl/{perl_version}/Courier/Config.PM
260 use constant COURIER_RUNTIME_DIR => '/var/run/courier'; # Normally '/var/run/courier'.
264 use constant COURIER_RUNTIME_DIR => '/var/lib/courier'; # Normally '/var/run/courier'.
266 Step Five - Create a symlink to pureperlfilter
268 ln -s /usr/bin/pureperlfilter /etc/courier/filters/active/
270 Step Six - Start the filter
272 /etc/rc.d/init.d/courier restart
278 This will show you how to prevent duplicate messages from coming into Courier.
279 This is not a 100% fool proof solution, but it does work.
281 Step One - Start the Dupfilter
283 courierfilter start dupfilter
290 This will show you how to scan for SPAM site wide using Spamassassin with courier.
291 This works with virtual users but not virtual domains. Virtual domains require an
292 additional module available at http://da.andaka.org/Doku/courier-spamassassin.html.
294 Step One - Install Spamassassin
296 perl -MCPAN -e shell [as root]
297 o conf prerequisites_policy ask
298 install Mail::SpamAssassin
302 Step Two - Creating a Spam User and Group
304 You will need to change ### to a userid.
306 echo "spam:x:###:###:Spam Assassin Server:/home/spam:/bin/bash" >> /etc/passwd
307 echo "spam:x:###:" >> /etc/group
310 Step Three - Create an init.d script for spamassassin
312 # Start /etc/rc.d/init.d/spamd
317 source /etc/sysconfig/rc
320 if [ -f /etc/sysconfig/spamd ]
322 source /etc/sysconfig/spamd
328 echo "Starting Spam Assassin Service..."
329 loadproc spamd $OPTIONS
333 echo "Stopping Spam Assassin Service..."
348 echo "Usage: $0 {start|stop|restart|status}"
352 # End /etc/rc.d/init.d/spamd
354 Step Four - Create an /etc/sysconfig/spamd for spamassassin
356 # Start /etc/sysconfig/spamd
358 OPTIONS="-d -c -a -q -x -u spam"
360 # End /etc/sysconfig/spamd
362 Step Five - Make Spamassassin start just before your Mail Server
364 cd /etc/rc.d/init.d &&
365 ln -sf ../init.d/spamd ../rc0.d/K26spamd &&
366 ln -sf ../init.d/spamd ../rc1.d/K26spamd &&
367 ln -sf ../init.d/spamd ../rc2.d/K26spamd &&
368 ln -sf ../init.d/spamd ../rc3.d/S34spamd &&
369 ln -sf ../init.d/spamd ../rc4.d/S34spamd &&
370 ln -sf ../init.d/spamd ../rc5.d/S34spamd &&
371 ln -sf ../init.d/spamd ../rc6.d/K26spamd
373 Other Spamassassin Configuration
377 In directory /etc/mail/spamassassin there is a file named local.cf, this contains all
378 the configuration information for your Spam Assassin Configuration. You will need to
379 add the following lines for your internal mail not be to scanned.
381 whitelist_from *@example.com
383 If you subscribe to mailling lists, you may want to add the mailling lists in like the
386 whitelist_to spamassassin-users@incubator.apache.org
387 whitelist_from spamassassin-users@incubator.apache.org
391 You can add other rules into the /etc/mail/spamassassin directory. All you have to do
392 is either create them or download them. Here is a good one to add for those stupid
393 buy drugs online stuff.
395 Download antidrug.cf from http://mywebpages.comcast.net/mkettler/sa/antidrug.cf
397 Put the file into /etc/mail/spamassassin and issue the following command
398 /etc/rc.d/init.d/spamd restart
400 Where can I get more rules
402 You can get more rules from the links below.
404 Note: Check you syslog for message about errors.
405 If you see an error message, it will tell you what file is having the problem.
406 You can either fix it or remove that rule set.
408 Example Error Message :
409 Subroutine J_CHICKENPOX_65_body_test redefined at /etc/mail/spamassassin/chickenpox.cf
413 http://www.merchantsoverseas.com/wwwroot/gorilla/sa_rules.htm
414 http://wiki.apache.org/spamassassin/CustomRulesets
420 CHANGELOG: 1.1 Forgot attachment
423 New Version of this document can be viewed from http://cvs.jg555.com/viewcvs.cgi/lfs-hints