1. Skip to Menu
  2. Skip to Content
  3. Skip to Footer>
Saturday Apr 27th     4:57 PM PDT                                  

Switch to MailDirs

PDF Print E-mail

Written by Greg King Friday, 27 November 2009 17:35

The sendmail system we recently set up uses the unix login account for mail distribution.  This is problematic in that email hosts need to give a login account to every user who wants email.  Additionally, the account names might need to be used again for a different domain.  The solution?  Maildirs.


 What is a maildir and why do I want it?


We configured sendmail which by default uses user directories for it's mail.  So, generally speaking, This e-mail address is being protected from spambots. You need JavaScript enabled to view it will have it's mail delivered to a directory called /home/president/.mail.  In my case, I host websites for youth baseball leagues.  Each league has it's own president meaning I can't use account names unless I use virtusertable variables as well.

Maildirs fix this problem because it uses /var/mail/<user> file structure.  This means that you don't need a user login account to host a user's mail.  Additionally, the file structure is domain inclusive.  the user This e-mail address is being protected from spambots. You need JavaScript enabled to view it will have a maildir called /var/mail/ This e-mail address is being protected from spambots. You need JavaScript enabled to view it thus allowing more than one president account to be used.


Forwarding Contents of User Mailbox:


It won't do us a lot of good to switch to maildirs if our existing users lose their email, so we will forward existing mail to the new maildir tree using procmail.

To start, we are going to view the installed packages to see if we already have procmail installed.

# pkg_info|grep procmail

if it is not installed, install it.

# portinstall mail/procmail

Now you can forward the entire contents of a user's mailbox with the following command:

# formail -s sendmail This e-mail address is being protected from spambots. You need JavaScript enabled to view it < /var/mail/user

you need to repeat this process for each user your host email for.


 Procmail Reconfiguration to use Maildir (Forces Sendmail delivery to Maildir)


This is the easy way to patch the default delivery to each user's $HOME/Maildir/

# cd /usr/ports/mail/procmail/work/procmail-3.22/src
# nano +50 authenticate.c

modify the line by removing the /* at the beginning and changing /.mail to read /Maildir/ so that it looks like the line below.

#define MAILSPOOLHOME "/Maildir/"                     /* watch the leading / */

                                               
NOTE: If mail/procmail has been 'cleaned' (the work directory doesn't exist), simply do 'make' again to create the 'work' files and then do the above.

Now, install procmail with the new settings.

# cd /usr/ports/mail/procmail

# make deinstall

# make reinstall

 

  Configuring an E-Mal Server
eXTReMe Tracker
Content View Hits : 404578