Tool-BarfreeBSD ArticlesSearch Our SiteHOMEfreeBSD LinksContribute to FreeBSD HelpFreeBSD FilesFreeBSD Script Corner

Mail services – setting up Home directory Mail spooling

Ted Wisniewski

The reasons to do "Home directory" spooling are many… Here is a couple of really good reasons:

    • All user files will be in one place, less system administration to maintain.
    • 1 filesystem with quotas (as opposed to have one for user files and another for mail)

What you will need:

  • Procmail (to be used as a local delivery agent) the current version is procmail-3.11pre7.tar.gz and can be retrieved from in the /pub/packages/procmail directory.
  • Sendmail version 8.9.1 or better. This can be retrieved from in the /pub/sendmail directory.
  • Mail readers Elm/Pine (installed as packages) and POP/IMAP mail servers (installed from source).

Now that you have the two essential pieces of software we need to extract the files, build and install them.

Procmail –

      • cd /var/tmp
      • tar zxvf procmail-3.11pre7.tar.gz
      • cd procmail-3.11pre7/src
      • Edit the authenticate.c file and uncomment the following line:
      • /*#define MAILSPOOLHOME "/.mail" /* watch the leading / */
      • The first two characters on the line need to be removed, it should look like (below) when done.
      • #define MAILSPOOLHOME "/.mail" /* watch the leading / */
      • cd ..
      • make
      • (as the root user) make install-suid
      • ln –s /usr/bin/procmail /usr/local/bin/procmail

Sendmail –

    • cd /var/tmp
    • tar zxvf sendmail.8.9.1.tar.gz
    • cd sendmail.8.9.1
    • make
    • (as the root user) make install
    • Now a "" file must me generated for the host, the one that came with the system is not adequate for our needs (we need to use sendmail as the delivery agent to get the mail spooled into the users' home directory).
    • cd cf/cf and edit the file called
    • add the following "Features"
    • FEATURE(local_procmail)
    • FEATURE(relay_entire_domain)
    • FEATURE(relay_local_from)

Remove the following line:


    • make
    • cp /etc/
    • vi /etc/, If this file does not already exist, create it, and for each "name" your host has put and entry for that hostname.
    • Example contents of /etc/ file:
    • cat /var/run/, the listed number (PID) is the process ID of the currently running sendmail daemon, do kill –9 PID, where PID is that number.
    • Restart sendmail: /usr/sbin/sendmail –bd –q30m

Now, You must tell your mail-readers where the mail is now spooled, most of them assume /var/mail or some other centralized place.

For (using csh or tcsh) "elm" and "mail" they respect the "MAIL" environment variable. You can set it in /etc/csh.cshrc as follows:

setenv MAIL ~/.mail

For pine, you need to edit your system-wide Pine configuration file usually /usr/local/etc/pine.conf and add:


For POP/IMAP mail readers, you will need to download the source for imap-4.4.tar.Z from in the /pub/FreeBSD/ports/distfiles directory.

Extract the archive: tar zxvf imap-4.4.tar.Z

You need to make 1 modification to imap-4.4/src/osdep/unix/env_unix.c, comment out or remove the line indicated below add/replace that line with the one provided.

char *sysinbox ()
char tmp[MAILTMPLEN];
if (!sysInbox) { /* initialize if first time */
/*sprintf (tmp,"%s/%s",MAILSPOOL,myusername ()); /*REMOVE*/
sprintf (tmp,"%s/%s",myHomeDir,"/.mail"); /*ADD*/
sysInbox = cpystr (tmp); /* system inbox is from mail spool */
return sysInbox;

Then build the POP3 and IMAP servers by doing "make bsf" in the imap-4.4 directory.

Upon completion of the build do the following as root (I assume you have backed up older versions if you are overwriting older executables):

cp imapd/imapd /usr/local/bin/imapd
chmod 755 /usr/local/bin/imapd

cp ipopd/ipop3d /usr/local/bin/ipopd
chmod 755 /usr/local/bin/ipopd

Now edit /etc/inetd.conf and make sure your pop3 & imap entries appear like:

pop3 stream tcp nowait root /usr/local/bin/ipop3d ipop3d
imap stream tcp nowait root /usr/local/bin/imapd imapd

If /etc/inetd.conf requires editing, you will need to "kill -HUP" the inetd process ("kill -HUP `/var/run/`")

© 1997 - 20013 Defcon1, , Copyrights for all materials on this web site are held by the individual authors, artists, photographers or creators. Materials may not be reproduced or otherwise distributed without permission of and the content's original author.

Tool-Bar-2Defcon1  Webmail