2 LFS VERSION: 3.3, 4.0 and CVS
3 AUTHOR: Richard Downing <richard.downing@bcs.org.uk>
6 How to set up xmail-1.11 instead of sendmail, postfix, qmail at al.
9 This hint explains how to build and set up xmail on your LFS system. Xmail, by
10 Davide Libenzi, is a single server which replaces, say,
11 sendmail+qpopper+fetchmail, or as I used on an LFS system long ago,
12 postfix+procmail+fetchmail+qpopper.
14 And since I know that this hint is linked to from the Xmail website, I should
15 add for Xmail readers that LFS = Linux From Scratch - the best way to learn
16 Linux and Unix, by building one from sources: Visit
18 http://www.linuxfromscratch.org
20 Why Xmail? Basically: why install three or four packages when one will do the
23 The big problem with xmail-1.11 is that Davide hasn't got around to writing
24 either a configure script or an installation script. This presents just a few
25 interesting opportunities for error, especially if you are still a bit
26 unix-challenged. However once the package is installed it appears to work well
27 and do what it is advertised to do.
29 There is an active, knowledgable, but a bit busy, mailing list.
31 I have used these instructions on a number of LFS builds, including my latest,
33 LFS CVS20021105 with glibc-2.3.1/gcc-3.2.1, with complete success.
35 Obtain and Unpack the package.
36 ------------------------------
38 Download the package from: http://www.xmailserver.org
40 It's a .tar.gz, so unpack in the usual way, and cd xmail-1.11. (Note: I've used
41 this process to build Xmail's since version 1.8, so I expect they will still
42 work for the next few releases - let me know if they let you down or need
45 Start by checking out the documentation in the docs directory: Readme.html or
46 Readme.txt is the only manual!
48 Build the executables.
49 ----------------------
50 Choose your Makefile depending on the architecture of your LFS machine:
52 make -f Makefile.lnx - for an i86 box
53 make -f Makefile.slx - for a SPARC
54 make -f Makefile.plx - for a PPC
56 (Note I only have experience with i86)
58 You can strip the executables now if space is an issue.
60 This will build Xmail and it's toolset, this includes a SysV init script which
61 works on a LFS system, but more on that later.
66 This is where the fun comes. Su to root if you are not already.
69 chmod 700 /var/MailRoot
71 Most of XMail's files are held in /var/MailRoot, which is only accessable by
74 cp XMail XMCrypt MkUsers sendmail /var/MailRoot/bin
76 However the CtrlClnt binary needs to be accessible to whoever is going to
77 administer the xmail system:
81 Copy the Manual to appropriate places:
83 cp -p Readme.txt /usr/share/xmail/Manual.txt
84 cp Readme.html /usr/share/xmail/Manual.html
86 If you plan to use Davide's init script copy it now:
88 cp xmail /etc/rc.d/init.d
90 Or create a more LFS-like script, such as:
92 cat > /etc/rc.d/init.d/xmail << "EOF"
95 # Begin $rc_base/init.d/XMail
97 # Based on sysklogd script from LFS-3.1 and earlier.
98 # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
100 # XMail init script by Richard A Downing - richard.downing@bcs.org.uk
101 # using LFS template and XMail-1.11 skeleton.
103 source /etc/sysconfig/rc
106 export MAIL_ROOT=/var/MailRoot
107 export MAIL_CMD_LINE="-Qn 2 -Pl -Sl -Fl -Cl -Ll"
108 PATH=$XMAIL_ROOT/bin:$PATH
112 echo "Starting XMail ..."
113 loadproc $MAIL_ROOT/bin/XMail
117 echo "Stopping XMail ..."
122 echo "Reloading XMail ..."
137 echo "Usage: $0 {start|stop|reload|restart|status}"
142 # End $rc_base/init.d/XMail
146 Replace or create a sendmail script
147 -----------------------------------
149 If your MUA (Kmail, for instance) interfaces (when sending mail) with the MTA
150 using SMTP you can skip this step entirely, but some MUA's need a sendmail
151 script which you can create like this.
153 The sendmail executable needs the SETGUID bit set to run as root and this might
156 If you already have a sendmail script or program, move it aside (your's might be
157 in /usr/bin or elsewhere):
159 mv /usr/sbin/sendmail /usr/sbin/sendmail.orig
161 Copy Xmail's sendmail executable to an appropriate place, and set it's SETUID
162 bit so that it runs as root.
164 cp sendmail /usr/sbin/sendmail.xmail
165 chmod +s /usr/sbin/sendmail.xmail
167 And create a sendmail script to set the environment and call the executable:
169 cat > /usr/sbin/sendmail << "EOF"
171 # This script sets the environment for XMail's sendmail and then calls it.
172 # The script exists so that software that expects sendmail can use XMail.
174 if [ -z $MAIL_ROOT ]; then
175 export MAIL_ROOT=/var/MailRoot
177 /usr/sbin/sendmail.xmail $*
178 # End /usr/sbin/sendmail
181 chmod +x /usr/sbin/sendmail
183 Configure Xmail's server.tab.
184 -----------------------------
186 It's important to note that all of xmail's configuration files use the 'tab'
187 character as a separator character - don't use spaces or extra tabs, and every
188 line, EVEN THE LAST ONE in a file must have a terminating <return>. For this
189 reason, apart from the following, I don't edit the tab files directly, prefering
190 the control interface, see later.
192 Use your favourite text editor to edit /var/MailRoot/server.tab for your domain
193 name, and set the names of the user's who will get error and postmaster
196 The files as delivered contain a reasonable starting point with a domain called
197 'xmailserver.test' which you can use to try things out if you want.
199 The server configuration variables are well described in part 12 of
200 the Manual (which you saved in /usr/share/xmail/Manual.txt !) - so check what
201 your situation needs. My server.tab is:
203 "RootDomain" "109bean.org.uk"
204 "POP3Domain" "109bean.org.uk"
205 "PostMaster" "root@109bean.org.uk"
206 "ErrorsAdmin" "root@109bean.org.uk"
207 "DefaultSMTPGateways" "smtp.your-isp.com"
208 "RemoveSpoolErrors" "0"
210 "ReceivedHdrType" "0"
211 "FetchHdrTags" "+X-Deliver-To,+Received,To,Cc"
212 "Pop3SyncErrorAccount" "root@109bean.org.uk"
213 "DefaultSmtpPerms" "MRVZ"
215 (note: I have not registered 109bean.org.uk, as it's never seen outside of my
218 Setup the domain.tab file to contain the name of your domain:
221 Now set up a 'control' account, I called mine 'root'. Choose a nice complicated
222 password and find its encrypted form with XMCrypt, I'll use 'ciao' as an
224 /var/MailRoot/bin/XMCrypt ciao
226 Now edit /var/MailRoot/ctrlaccounts.tab to read something like this, where the
227 second element is the string that XMCrypt returned:
230 Note the double-quotes are really there in the file and the separator IS a
231 single 'tab' and the line IS terminated with a <return>. Wherever a 'tab' file
232 format calls for a password, it's an XMCrypt password that's needed - this
233 caused me a lot of problems!
235 You will need at least one user set up in /var/MailRoot/mailusers.tab, and while
239 you are editing it delete the sample account for 'xmailuser', remember to use
240 XMCrypt to find your encrypted password.
242 and that is sufficient to get XMail running.
244 Start XMail for the first time.
245 -------------------------------
247 Start XMail in debug mode with the following commands:
249 export MAIL_ROOT=/var/MailRoot
250 /var/MailRoot/bin/XMail -Md -Pl -Sl -Fl -Cl -Ll ...
252 where the ... are any other command line switches you might want or need - see
253 part 19 of the Manual. (By the way those switches end with a lower case L - not
254 obvious in some fonts!)
256 You will see the various XMail threads start up, and if all looks stable you
257 have a working XMail. If you can start another terminal session, a second xterm
258 or login on another tty, then you can command XMail (see next session) and watch
259 the debugging output. When you are happy, hit Ctrl-C and abort the run,
260 watching XMail shut down it's threads gracefully.
262 Setup the SysV init script.
263 ---------------------------
265 Link the SysV init script as you see fit into the rc.d system, I set:
268 ln -s init.d/xmail rc0.d/K27xmail
269 ln -s init.d/xmail rc1.d/K27xmail
270 ln -s init.d/xmail rc2.d/K27xmail
271 ln -s init.d/xmail rc6.d/K27xmail
272 ln -s init.d/xmail rc3.d/S43xmail
273 ln -s init.d/xmail rc4.d/S43xmail
274 ln -s init.d/xmail rc5.d/S43xmail
276 although I actually do it with KDE3's SysV-Init editor.
278 The aim is to close xmail before the network goes down, but after any activity
279 which might cause mail activity, and to start xmail after the network is up, but
280 before starting anything that might generate mail (for example: fcron).
282 Now you can run the xmail daemon properly by issuing:
284 /etc/rc.d/init.d/xmail start
286 which will fork the daemon and display its process id (pid). Now you can set up
287 your other accounts and the links to mail servers at your ISP, and becuase you
288 are asking XMail to do it for you, you are assured that the setup will be
291 Setting up another user account.
292 --------------------------------
293 Type the following, you don't need to be 'root':
295 /usr/bin/CtrlClnt -s 109bean.org.uk -u root -p ciao \
296 useradd 109bean.org.uk newuser newpassword U
298 Of course, you need to substitute your domain name, Control Account and
301 In these CtrlClnt (Control Client) commands you should NOT use MKCrypt-ed
304 Once the user account(s) are set up, you can try sending mail between them
305 locally. Set up your MUA, say Mutt or Kmail, to send via smtp localhost:110,
306 and receive by POP3 from '109bean.org.uk' or whatever your domain is
307 called, with the appropriate username and password as just setup.
309 Setting up a POP3 drop from your ISP.
310 -------------------------------------
311 Assuming your ISP presents a simple unencrypted (old-fashioned) POP3 service,
312 you need to know your login name (you-at-isp) and password
313 (your-isp-pop-password)and the address of the POP3 server.
315 /usr/bin/CtrlClnt -s 109bean.org.uk -u root -p ciao \
316 poplnkadd 109bean.org.uk richard \
317 pop3.isp.com you-at-isp your-isp-pop-password CLR
319 This will set up an automatic synchonisation between XMail and your pop3 account
322 at pop3.isp.com, syncronising every 2 minutes (120 seconds).
323 To change the synchronisation rate to, say, every 5 minutes, you need to edit
325 command line switch -Yi 300 (300 seconds) in /etc/rc.d/init.d/xmail.
327 If your ISP supports APOP authorisation substitute APOP for CLR above.
329 That's all I did, and it works for me. Good luck.