## Migrating from Sendmail on a FreeBSD System 
  ## Nathan Underwood <> 
  Intro
  As we talked about in last month's issue, qmail is "a secure, reliable,
  efficient, and simple message transfer agent." If you need a refresher on
  what qmail is all about, please go back and read the first article in the
  series.  This month we are going to take a step by step and easy approach to
  configuring qmail on a FreeBSD system running sendmail.  Before we begin, we
  will need a few things: 
  
- The qmail source (available from )
 
- A system running FreeBSD 2.2.x - 3.x
 
- Root user access
 
 
  With these items taken care of, we are ready to begin. 
  8 Easy steps to installing qmail
  1. Unpacking the source
  The first thing you will need to do is unpack the source that you have
  just downloaded.  To do so, issue the following command: 
  	$ tar -zxvf qmail-1.03.tar.gz
	$ cd qmail-1.03
   
  2. Creating our qmail directory and adding the qmail users
  Now that we are in our qmail source directory, we can begin getting ready
  to install qmail. I highly recommend reading all (see below) of the
  documentation for qmail that is included with the source; it will give you a
  greater understanding of what we are doing in the paragraphs that follow. As
  root: 
  	# mkdir /var/qmail
	# pw groupadd nofiles
	# pw useradd alias -g nofiles -d /var/qmail/alias -s /nonexistent
	# pw useradd qmaild -g nofiles -d /var/qmail -s /nonexistent
	# pw useradd qmaill -g nofiles -d /var/qmail -s /nonexistent
	# pw useradd qmailp -g nofiles -d /var/qmail -s /nonexistent
	# pw groupadd qmail
	# pw useradd qmailq -g qmail -d /var/qmail -s /nonexistent
	# pw useradd qmailr -g qmail -d /var/qmail -s /nonexistent
	# pw useradd qmails -g qmail -d /var/qmail -s /nonexistent
   
  3. Compiling
  This will install the binaries to /var/qmail and set up your rcpthosts and
  locals files with your machine's hostname information. 
  	# make setup check
	# ./config
   
  4. System aliases
  We need to create a few system aliases that qmail will use extensively.
  These aliases are the root, postmaster, and mailer-daemon aliases, and they
  must be in place for qmail to function smoothly.  To create the aliases: 
  	# cd /var/qmail/alias
	# touch .qmail-postmaster .qmail-mailer-daemon .qmail-root
	# chmod 644 .qmail*
   
  You will then need to tell qmail where to send the mail for these aliases
  by adding one or more usernames to the files.  If your username on your
  system was "bob", and you were the only user who was going to receive root,
  postmaster, and mailer-daemon messages, then you would add a single line to
  each file in the form of "&bob", which would send all mail to root,
  postmaster, and mailer-daemon to user bob's mailbox (an easy way to do this
  would be '# echo "&bob" > .qmail-root', etc.). 
  5. Copying the startup script
  	# cp /var/qmail/boot/home to /var/qmail/rc
   
  This will allow qmail to be started at boot time after you have edited your
  /etc/rc.conf and /etc/inetd.conf files (see #8). 
  6. Killing the sendmail process
  First we need to kill the sendmail process that is running and keep it from
  restarting.  To begin, we must stop sendmail from running the queue.  To do
  this, you must comment out the line 'sendmail_flags="-bd -q30m' in
  your /etc/rc.conf file (for FreeBSD 2.2.x - 3.0) or in your
  /etc/defaults/rc.conf file in FreeBSD 3.1.  We also need to make sure that
  'sendmail_enable="NO"' in /etc/rc.conf (all).  Then, we must kill the sendmail
  process.  Assuming you have nothing in your mail queue (if you do, wait until
  it is flushed to kill sendmail), execute these commands: 
  	# killall -STOP sendmail
	# killall -CONT sendmail
	# killall -TERM sendmail
   
  Now we must change the permissions on the sendmail binary and move it out
  of the way. 
  	# chmod 0 /usr/sbin/sendmail
	# mv /usr/sbin/sendmail /usr/sbin/sendmail.bak
   
  Ok, now a 'ps -aux | grep sendmail' should return nothing; sendmail has
  been successfully killed. 
  7. Killing binmail
  Assuming you haven't configured qmail to use binmail for local delivery
  (which we haven't done here), we can safely remove the binmail binary. 
  	# chmod 0 /usr/libexec/mail.local
   
  Now,  comment out the comsat line in /etc/inetd.conf, and kill -HUP your
  inetd. 
  That's it; sendmail has now been shut off.  However, if for some reason
  you do not want to use qmail or decide you want sendmail as your MTA again,
  simply reverse the process that we have done above and everything will be as
  it was. 
  8. Boot scripts and rebooting
  Now that sendmail has been disabled and qmail is ready to go, we have to
  ensure that the qmail processes will start upon rebooting the machine.  To
  begin, we need to add the line csh -cf '/var/qmail/rc &' to /etc/rc.conf so
  that the qmail processes will start upon booting (or rebooting) the machine.
  Second, we need to add a line to /etc/inetd.conf (all one line): 
  	smtp stream tcp nowait qmaild /var/qmail/bin/tcp-env tcp-env /var/qmail/bin/qmail-smtpd
   
  Lastly, we need to make qmail's "sendmail" wrapper available to various
  MUAs: 
  	# ln -s /var/qmail/bin/datemail /usr/sbin/sendmail
   
  That's it...qmail is now configured. All we have to do now is reboot the 
  computer.  Upon restarting, do a ps -aux to make sure that all of the various
  qmail processes are running, and then go ahead and send yourself some mail to
  create a Mailbox file in your home directory.  You will likely have to
  reconfigure your mail client (pine, mutt, elm, etc.) to look for your mail in
  ~/Mailbox as opposed to /var/mail/username. 
  Closing remarks
  Now that qmail is configured, you may be saying, "I don't really see how
  this is any better than sendmail" or "It seems almost the same as sendmail".
  True, if you simply want to get your mail, then qmail doesn't necessarily
  stand out above sendmail; but, as we will discover in the next few issues,
  qmail has some very nice configuration features (not to mention the security
  aspect that we discussed in last month's issue) that stand heads above
  sendmail. 
  Next month we will be discussing ways in which to make the change from
  sendmail transparent to any users that are on your system; discussing topics
  such as .forward files, .qmail files, and user aliases. 
  Important qmail documentation to read (in /var/qmail/docs)
  	INSTALL
	INSTALL.ids
	INSTALL.ctl
	INSTALL.alias
	SENDMAIL
	REMOVE.sendmail
	REMOVE.binmail
	TEST.receive
   
  If you have any questions, find yourself stuck, or find a mistake in this
  article, please  don't hesitate to email me at
  .  I'll do my
  best to respond to any questions you may have regarding this article or qmail
  in general. 
  Nathan 
  Return to Issue #4 
   |