root/trunk/courier-extras.txt

Revision 809, 10.6 kB (checked in by tushar, 5 years ago)

Modified: courier-extras

Line 
1 AUTHOR:         Jim Gifford <lfs-hints at jg555.com>
2
3 DATE:           2004-03-25
4
5 LICENSE:        GNU Free Documentation License Version 1.2
6
7 SYNOPSIS:       How to setup the Extra Capabilities in Courier
8
9 DESCRIPTION:    This hint will show you how to use feature of the Courier Mail
10                 Server that are not mentioned in BLFS
11
12 PREREQUISITES:  Courier, Mgetty, Virus Scanner
13
14 HINT:
15
16 ------
17
18 Courier Maillist List Manager
19
20         This will show you the process on how to setup Courier's Mailing List.
21
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
25
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
29
30                                
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','');
36
37         Step Three : Create .courier in the {directory} with the following information
38                 | couriermlm msg {directory}
39                 Example : couriermlm msg /home/test-list
40                        
41         Step Four : Create .courier-default in the {directory} with the following information
42                 | couriermlm ctlmsg {directory}
43                 Example : couriermlm ctlmsg /home/test-list
44                        
45         Step Five : Create .courier-owner in the {directory} with the following information
46                 owner_of_list@example.com
47                 Example : listmanager@example.com
48
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
52
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
56                
57
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
60
61 -----
62
63 Amavis
64        
65 Prerequisites:  A Virus Scanner
66
67         This will show you how to setup Amavis(Mail Virus Scanner) to work with Courier.
68
69         Before you can install Amavis, you will need to install a virus scanner. The one
70         I have been using is Clamav.
71
72         Download location (HTTP):       
73         http://osdn.dl.sourceforge.net/sourceforge/clamav/clamav-0.67.tar.gz
74
75         Installation of Clamav
76        
77         ./configure --prefix=/usr \
78                     --sysconfdir=/etc/clamav
79         make
80         make install
81
82         Now for the installation of Amavis
83
84         Download location (HTTP):       
85         http://osdn.dl.sourceforge.net/sourceforge/amavis/amavis-0.3.12.tar.gz
86        
87         Need Patches
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
90
91         Step One - Install Amavis required perl modules
92
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'
103
104         Step Two - Create Amavis Executable
105        
106         ./reconf
107         ./configure --prefix=/usr \
108                     --enable-courier \
109                     --enable-syslog \
110                     --with-syslog-level=mail.info \
111                     --with-amavisuser=amavis   
112
113
114         Step Three - Configure Courier
115
116                 In /etc/courier/courierd
117
118                 Change the DEFAULTDELIVERY=./Maildir to DEFAULTDELIVERY="| /usr/bin/maildrop"
119
120                 For All users
121
122                 In /etc/courier/maildroprc
123
124                 Add the following:
125
126                 # Virus Scan
127                 #
128                 import SENDER
129                 import RECIPIENT
130
131                 if ($SENDER ne "")
132                         {
133                                 FROM=escape($SENDER)
134                         }
135                         else
136                         {
137                                 FROM="unknown@example.com"
138                         }
139
140                 if ($RECIPIENT ne "")
141                         {
142                                 TO=escape($RECIPIENT)
143                         }
144                         else
145                         {
146                                 TO="unknown@jg555.com"
147                         }
148
149                 xfilter "/usr/sbin/amavis $SENDER $RECIPIENT"
150
151                 # Drop anything listed as a Virus into .Virus
152                 #
153                 if (/^Subject:.*VIRUS FROM*/)
154                         to "$DEFAULT/.Virus/"
155
156                 # Drop anything listed as a Virus into .Virus
157                 #
158                 if (/^Subject:.*VIRUS TO*/)
159                         to "$DEFAULT/.Virus/"
160
161                 For Individual Users
162
163                 Create the same information as above only as .mailfilter in the users
164                 home directory.
165
166 -----
167
168 Mailing List Filtering
169
170         This will show you how to filter Mailing Lists that you subscribe to into different
171         IMAP folders.
172
173         Step One
174
175                 Go to the Maildir in the users home directory. maildirmake .{list_name}.
176                
177                 Example : maildirmake .lfs-dev
178
179         Step Two
180
181                 Make sure the newly created .{listname} has the proper user permission.
182                 chown {user:user} .{listname} -R
183
184                 Example chown jim:jim .lfs-dev -R
185
186         Step Three
187
188                 Edit .mailfilter in the users home directory. Add the following information to
189                 .mailfilter.
190
191                 # {list_name}
192                 #
193                 if (/^List-Post:.*{list_address@*/)
194                         to "$DEFAULT/.{list_name}/"
195
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.
199
200                 # lfs-dev
201                 #
202                 if (/^List-Id:.*lfs-dev.linuxfromscratch.org*/)
203                         to "$DEFAULT/.lfs-dev/"
204
205 ----
206
207 Courier Fax
208
209         This will show you how to setup Faxing within Courier.
210
211         Step One - If mgetty is not installed, follow the mgetty hint.
212                 Hint Link : http://www.linuxfromscratch.org/hints/downloads/files/mgetty.txt
213
214         Step Two - Locate Faxq-helper
215
216                 Find Mgetty's faxq-helper program and Change into the directory that it is
217                 located in.
218
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
222
223         Step Three - Create a symlink for new_fax
224
225                 ln -sf /usr/share/courier/new_fax
226
227         How to Use
228                
229                 Send an email to {phone_number}@fax, this will fax to the phone number specified.
230
231                 Note: This does not work with Outlook Express
232
233 -----
234
235 Courier Filter
236
237         This will show you how to use the Courier::Filter framework with Courier.
238
239         Step One - Install Courier Filter required perl modules
240
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'
245
246         Step Two - Install Courier Filter
247
248                 perl -MCPAN -e 'install Courier::Filter'
249
250         Step Three - Create pureperlfilter.conf
251
252                 You can retrieve a sample perlpurefilter.conf from
253
254                 http://www.linuxfromscratch.org/hints/downloads/attachments/courier-extras/pureperlfilter.conf
255
256         Step Four - Edit /usr/lib/perl5/site_perl/{perl_version}/Courier/Config.PM
257                
258                 Change
259
260                 use constant COURIER_RUNTIME_DIR    => '/var/run/courier';  # Normally '/var/run/courier'.
261
262                 to
263
264                 use constant COURIER_RUNTIME_DIR    => '/var/lib/courier';  # Normally '/var/run/courier'.
265
266         Step Five - Create a symlink to pureperlfilter
267
268                 ln -s /usr/bin/pureperlfilter /etc/courier/filters/active/
269
270         Step Six - Start the filter
271
272                 /etc/rc.d/init.d/courier restart
273
274 -----
275
276 Dupfilter
277
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.
280
281         Step One - Start the Dupfilter
282
283                 courierfilter start dupfilter
284                        
285                        
286 -----   
287
288 Spamassassin
289
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.
293
294         Step One - Install Spamassassin
295
296                 perl -MCPAN -e shell                    [as root]
297                 o conf prerequisites_policy ask
298                 install Mail::SpamAssassin
299                 quit
300
301        
302         Step Two - Creating a Spam User and Group
303
304                 You will need to change ### to a userid.
305
306                 echo "spam:x:###:###:Spam Assassin Server:/home/spam:/bin/bash" >> /etc/passwd
307                 echo "spam:x:###:" >> /etc/group
308                 mkdir /home/spam
309
310         Step Three - Create an init.d script for spamassassin
311
312         # Start /etc/rc.d/init.d/spamd
313         #!/bin/bash
314
315         # SpamAssassin
316
317         source /etc/sysconfig/rc
318         source $rc_functions
319
320         if [ -f /etc/sysconfig/spamd ]
321                 then
322                         source /etc/sysconfig/spamd
323         fi
324
325
326         case "$1" in
327                 start)
328                         echo "Starting Spam Assassin Service..."
329                         loadproc spamd $OPTIONS
330                         ;;
331
332                 stop)
333                         echo "Stopping Spam Assassin Service..."
334                         killproc spamd
335                         ;;
336
337                 restart)
338                         $0 stop
339                         sleep 1
340                         $0 start
341                         ;;
342
343                 status)
344                         statusproc spamd
345                         ;;
346
347                 *)
348                         echo "Usage: $0 {start|stop|restart|status}"
349                         exit 1
350                         ;;
351         esac
352         # End /etc/rc.d/init.d/spamd
353        
354         Step Four - Create an /etc/sysconfig/spamd for spamassassin
355
356         # Start /etc/sysconfig/spamd
357
358         OPTIONS="-d -c -a -q -x -u spam"
359
360         # End /etc/sysconfig/spamd
361
362         Step Five - Make Spamassassin start just before your Mail Server
363
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
372
373 Other Spamassassin Configuration
374
375         White Listing
376
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.
380
381         whitelist_from  *@example.com
382
383         If you subscribe to mailling lists, you may want to add the mailling lists in like the
384         following.
385
386         whitelist_to    spamassassin-users@incubator.apache.org
387         whitelist_from  spamassassin-users@incubator.apache.org
388
389         More Rules
390
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.
394
395         Download antidrug.cf from http://mywebpages.comcast.net/mkettler/sa/antidrug.cf
396
397         Put the file into /etc/mail/spamassassin and issue the following command
398         /etc/rc.d/init.d/spamd restart
399
400         Where can I get more rules
401
402         You can get more rules from the links below.
403
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.
407
408         Example Error Message :
409         Subroutine J_CHICKENPOX_65_body_test redefined at /etc/mail/spamassassin/chickenpox.cf
410
411         Rules Links
412
413         http://www.merchantsoverseas.com/wwwroot/gorilla/sa_rules.htm
414         http://wiki.apache.org/spamassassin/CustomRulesets
415
416 -----
417
418 VERSION:        1.1
419
420 CHANGELOG:      1.1 Forgot attachment
421                 1.0 Initial Version
422
423  New Version of this document can be viewed from http://cvs.jg555.com/viewcvs.cgi/lfs-hints
Note: See TracBrowser for help on using the browser.