|
|
|
|
|
|
dlostboy (at) lostinfo (dot) com Home | Journal | Multimedia | Files | Other | Links | About |
|
|
|
FreeBSD 4.4 HOW-TO for Courier-IMAP w/ Procmail
Sometime or another, you may decide that using IMAP is the way to go. FreeBSD
does not ship with a IMAP daemon but has several in the ports tree. By far the
easiest to use is uw-imapd. Simply by compiling this port and editing your
inetd.conf to point to it, you've gained access to imap folders. The problem with
uw however is that it continues to put mail in /var/mail/username and
thus must also use that file for it's own data and that it's really not a fast
daemon in my experience (being traditionally called from inetd.conf doesn't help).
Having that extra data in the mail file causes a
strange email to show up every time you use POP3 on the box. Additionally, it's
not nearly as robust - not scaling well for large email collections. Many people
who switch to IMAP find that leaving mail on the server is rather handy, so it's
easy to wind up with an email box that's 20, 50, even 100MB (quota willing). The
option is to use MailDir's which is the idea of making a directory for email and
putting each message into it's own file instead of one big one.
Now if we change to using MailDir's we'll also have to change our LDA (Local
Delivery Agent) because mail.local will not deliver mail to MailDirs. We'll continue
to use sendmail for our MTA (Message Transfer Agent) since we like it. In looking
for a good solution, I decided that a widely used IMAP daemon to use would be
Courier-IMAP in conjunction with the LDA ProcMail. Both are in ports (although the
Courier port leaves a little to be desired). Lastly, if you were using qpopper for
POP3, you'll have to walk away from that too due to the MailDirs. Thankfully
Courier ships with a POP3 daemon too so we're ok there.
Courier stays running (as opposed to being called from inetd) and doesn't use alot
of ram. That's always good. Additionally, using ProcMail will allow us to do lots
of "cool" things like vacation messaging, autoresponders, forwarding, etc..
The way we will set things up will be using the default authentication built into
Courier (which is fine, and allows us to use less user accounts on the machine).
We are going to use this structure for our accounts:
Finally, we'll store all the authentication information in /usr/local/etc/. For these examples,
I'll use dlostboy@lostinfo.com as my email address, assuming that I have a user account
called dlostboy, and that I also want to get email at info@lostinfo.com which will have
an alias of sales@lostinfo.com (an alias is an email address that is simply mapped to another as
opposed to having separate mail space/password).For both accounts, I'd just like to use the
password "mypass".
We will now need to get the uid/gid for "dlostboy", so if you
That will write out a file in /usr/local/etc/userdb called "lostinfo.com" with a single
line in it that will start with "dlostboy@lostinfo.com". Now we'll add our second
virtual domain email user:
Now we'll set our passwords, echo'ing like this is horrible in practice since it'll show up in "ps"
but for this example we'll live with it...makes it easier for me to type this up.
Now until the port is fixed (wasn't in 8/2001) we have to
in order for the daemons to start when we reboot. For now we'll start them by:
Authenticated: module authuserdb
So, assuming that's working, lets test pop3d:
That's definately a good sign. At this point, we've verified that our
IMAP daemon and POP3 daemon are both working soundly. Lets move on
to setting up that alias we wanted to, and using ProcMail.
For the alias, we simply have to add it to our virtual users table.
Since we're gonna assume that you want to handle many virtual domains,
we'll say that you're storing VUT's for each domain separately, but all
in one directory. If that's the case, and that happens to be
/usr/local/etc/virtualusers/domainname.ext then we need to create
a file called /usr/local/etc/virtualusers/lostinfo.com and then put this
line in it:
rm /etc/mail/virtusertable
Now with that done, of course we have to add our domain to local-host-names, so
Now we have to change our LDA to be procmail. Open up /etc/mail/sendmail.cf in your
favorite text editor and find the line that reads:
Mlocal, P=/usr/libexec/mail.lcoal, F=lsDFMAw5:/|@qPSXfmnz9P, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL,
Change that to read:
With all of that done, now we have to tell ProcMail how to deliver the mail for your
domains. This is done through the /usr/local/etc/procmailrc file. This file should read:
GRR...what now? I don't know the MAILDIR....
|
| ©2000, ©2001 LostInformation |