1 TITLE: Postfix + procmail + fetchmail
2 LFS VERSION: 3.1 + lfsbootscript-1.0
3 AUTHOR: Michenaud Laurent <lmichenaud@free.fr>
6 How to set up postfix - procmail - fetchmail
9 This hint explains how to set up a mail server on your lfs
10 using postfix, procmail and fetchmail.
13 - a dns server => see the bind hint or the djbdns hint.
17 - a working fcron => see the fcrontab hint
23 download here : http://www.procmail.org/procmail-3.22.tar.gz
25 $ tar zxvf procmail-3.21.tar.gz
27 $ make BASENAME=/usr install
37 download here : ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-1.1.0.tar.gz
41 If db.h is not in /usr/include
42 or in /usr/include/db, make will failed.
43 To correct, edit makedefs, search for "db.h" and change the paths.
44 or use following commands :
46 sed 's|/usr/include/db.h|/path/to/db.h|' \
47 makedefs > makedefs~ &&
54 b) create a postfix user and the postfix group
57 postfix:x:101:101::/dev/null:/bin/false
66 /var/mail is owned by root on a standard lfs so
67 postfix can't create files inside it.
70 $ chown postfix.postfix /var/mail
75 # if new fresh install
80 if u choose make install, it will ask u about
81 the different directory u want to use.
86 config_directory : /etc/postfix
87 daemon_directory : /usr/libexec/postfix
88 command_directory: /usr/sbin
89 queue_directory: /var/spool/postfix
90 sendmail_path: /usr/sbin/sendmail
91 newaliases_path: /usr/bin/newaliases
92 mailq_path: /usr/bin/mailq
94 setgid_group: postdrop
95 manpage_directory: /usr/share/man
96 readme_directory: [no]
98 Then, you have to run :
99 /etc/postfix/post-install create-missing
101 If it cannot find postconf, that's because this script redefines $PATH.
102 Edit it to make it working.
105 $ /etc/postfix/post-install
107 At last, you can copy the html documentation
109 $ cp -rf html /usr/doc/postfix
112 With this new postfix version, i had to edit the
113 /etc/postfix/master.cf to make postfix working.
114 I've changed the following :
116 set flush and cleanup to private
117 I have the feeling it is not the good solution
118 but it works. Need help for this point.
122 2) The main configuration file : /etc/postfix/main.cf
123 -----------------------------------------------------
127 # Directories information
128 queue_directory = /var/spool/postfix
129 mail_spool_directory = /var/mail
130 command_directory = /usr/sbin
131 daemon_directory = /usr/libexec/postfix
136 default_privs = nobody
139 myhostname = zarba.zerezo.org
142 mydomain = zerezo.org
144 # Which address to use to send mail
147 # domain list from which the machine considers itself
148 # as the destination of the messages
149 mydestination = $myhostname, localhost.$mydomain, $mydomain, mail.$mydomain
151 #inet_interfaces = all
152 inet_interfaces = $myhostname, localhost
154 # which machines should postfix trust
155 # possible values are class subnet host
156 mynetworks_style = subnet
158 # At the place of mynetworks_style, you can use :
159 # mynetworks = 192.168.0.0, 127.0.0.1
161 # Which ISP to use to deliver the non local mail
162 relayhost = [smtp.laposte.net]
164 # Which protocol to use for local mail
165 default_transport = smtp
167 # Allow to postfix to know which address are local
168 # and which are external
169 transport_maps = hash:/etc/postfix/transport
171 # Alias file to change local address into valid external mail
172 sender_canonical_maps = hash:/etc/postfix/sender_canonical
174 recipient_canonical_maps = hash:/etc/postfix/recipient_canonical
177 alias_maps = hash:/etc/postfix/aliases
178 alias_database = hash:/etc/postfix/aliases
180 # Reject unknown users
181 local_recipient_maps = $alias_maps unix:passwd.byname
183 # Which program to use to deliver mail
184 mailbox_command = /usr/bin/procmail
186 # Concurrency processes
187 local_destination_concurrency_limit = 2
188 default_destination_concurrency_limit = 5
194 PATH=/usr/bin:/usr/X11R6/bin
195 xxgdb $daemon_directory/$process_name $process_id & sleep 5
197 # Minimum free space on disk to accept the mail
198 queue_minfree = 5000000
200 # maximum size of a mail
201 message_size_limit = 10000000
203 # Send a copy of error message to the postmaster
204 notify_classes = resource,software,bounce,delay,policy
206 # Pause in seconds to do when the message arrival
207 # rate exceeds the message delivery rate
210 sendmail_path = /usr/sbin/sendmail
211 newaliases_path = /usr/bin/newaliases
212 mailq_path = /usr/bin/mailq
213 setgid_group = postdrop
214 manpage_directory = /usr/share/man
215 sample_directory = /etc/postfix/sample
216 readme_directory = no
222 3) alias configuration : /etc/postfix/aliases
223 ---------------------------------------------
225 It allows you to redirect the mails of a user
226 to another user or severals users.
227 Edit /etc/postfix/aliases
232 familly: zarba, dad, mum, karine
234 Then, run to update the database file :
239 4) /etc/postfix/recipient_canonical
240 -----------------------------------
242 This allow to transform external addresses into
245 edit /etc/postfix/recipient_canonical
248 laurent.michenaud@laposte.net zarba
249 karine.michenaud@laposte.net karine
250 laurent.michenaud@wanadoo.fr zarba
253 Then, update the database file :
254 $ postmap /etc/postfix/recipient_canonical
257 5) /etc/postfix/sender_canonical
258 --------------------------------
260 This allows to transform your local address
261 into valid external addresses.
262 For example, my domain zarba.zerezo.org is not
263 registered on internet. So, when i send external mails,
264 my address should be change into a valid one.
266 edit /etc/postfix/sender_canonical
269 root laurent.michenaud@yourfai.com
270 karine karine.michenaud@yourfai.com
273 Then, update the database file :
274 $ postmap /etc/postfix/sender_canonical
278 6) /etc/postfix/transport
279 -------------------------
281 Postfix has to know which mails are local and
285 zarba.zerezo.org local:
288 Update the database file :
289 postmap /etc/postfix/transport
293 7) Postfix administration
294 -------------------------
296 postfix start : to start the mail server
297 postfix stop : to stop the mail server
298 postfix reload : to reload the mail server
299 postfix check : check the configuration and the permissions
300 postfix flush : to send the undelivered mail
301 mailq : to see mails which have not been delivered
306 8) the boot script /etc/rc.d/init.d/postfix
307 -------------------------------------------
309 # be carefull, it uses the new bootscripts-1.0 system
313 source /etc/sysconfig/rc
318 echo -n "Starting the mail server..."
319 /usr/sbin/postfix start
324 echo -n "Stopping the mail server..."
325 /usr/sbin/postfix stop
330 echo -n "Reloading the mail server..."
331 /usr/sbin/postfix reload
342 echo "Usage: $0 {start|stop|reload|restart}"
350 $ cd /etc/rc.d/init.d/rc0.d
351 $ ln -s ../init.d/postfix K05postfix
353 $ ln -s ../init.d/postfix K05postfix
355 $ ln -s ../init.d/postfix S45postfix
357 $ ln -s ../init.d/postfix S45postfix
364 download here : http://www.tuxedo.org/~esr/fetchmail/fetchmail-5.9.6.tar.gz
368 # You can add --with-ssl option to ./configure if u want( OpenSSL needed ).
370 $ ./configure --prefix=/usr --enable-fallback=procmail --sysconfdir=/etc
377 Edit ~/.fetchmailrc and add your mail accounts.
380 set logfile /var/log/fetchmail.log
385 user "isplogin" pass "isppassword" is zarba here ;
391 I've done a script which is run every ten minutes and
392 which gets my mail on my different mail account.
394 My script /root/bin/checkmail :
397 if [ -e /var/run/ppp0.pid ]
399 /opt/network/bin/fetchmail
402 The command in fcrontab :
403 $ fcrontab -u root -e
405 @ 10 touch /root/bin/checkmail -F
410 I used this fetchmail configuration when i had a non permanent connexion.
411 Since i have hot an adsl connexion, i didnot use anymore fcrontab for fetchmail.
412 I let run fetchmail as a daemon.
413 This can be done by adding this line in the file .fetchmailrc :
417 600 is the number of seconds between each mail check.
423 qpopper is a pop server. If u have a little network at home and
424 u want to be able to check your mail gathered by fetchmail from another
425 box, u have to install it.
428 ftp://ftp.qualcomm.com/eudora/servers/unix/popper/qpopper4.0.3.tar.gz
432 ./configure --prefix=/usr --sysconfdir=/etc
434 optional, u can add --with-openssl=/path/to/openssl
440 Add a service qpopper in xinetd :
448 server = /usr/sbin/popper
449 server_args = qpopper -s
451 only_from = 192.168.0.0
458 I have restricted qpopper so it is avaible only on
459 my network and not on internet.
465 This hint needs to be completed.
469 Amavis integration( virus scanner )