I started to work on this from the book FreeBSD 6 Unleashed. However I ran into some issues and started googling and ran across this article and suddenly everything started working. I'm going to duplicate the basic instructions here in case that that link every goes away.
This receipe is for using a combination of sendmail and the University of Washington's IMAP Server.
SendMail
A default install of FreeBSD 6 already includes sendmail. All that is needed is a configuration tweak to make sure that sendmail is capable of sending and receiving mail outside of the server itself. (The default install is just used to distribute mail among user on the server itself.)
Of course you need to make sure that port 25 is visible to the internet. This may involved opening or configuring port forwarding on your router/firewall. This is specific to your router/firewall so I can't delve into the details here.
The configuration teak that is needed is to enable sendmail by adding the line 'sendmail_enable="yes"' to the server rc.config file located under /etc. I believe a server reboot will be necessary after this config change.
University of Washington IMAP Server Install
Install mail/cclient from the FreeBSD ports system. Don't forget to add "-DWITH_SSL_AND_PLAINTEXT" to make to enable LOGIN and PLAIN auth support if you wish to support non-SSL-capable IMAP clients:
cd /usr/ports/mail/cclient make -DWITH_SSL_AND_PLAINTEXT install
Install mail/imap-uw from the FreeBSD ports system. Again, don't forget the "-DWITH_SSL_AND_PLAINTEXT" to turn on support for both SSL-encrypted and plain-text IMAP support if you plan on allowing access from non-SSL-enabled IMAP clients:
cd /usr/ports/mail/imap-uw make -DWITH_SSL_AND_PLAINTEXT install
Install an OpenSSL certificate. When you install the mail/imap-uw port you should see a message about "make cert" to generate a certificate for imapd and ipop3d to use.
make cert
Be sure you use the FQDN for your mail server when it asks for "Common Name."
(When I did this more recently I was not prompted to execute "make cert" but run it anyway. It will work. See also ./CertTip)
Edit /etc/inetd.conf to enable imapd and ipop3d on their respective secure ports. You can also turn on the standard (non-encrypted) versions if you want. The lines in your /etc/inetd.conf should look like this:
- imaps stream tcp nowait root /usr/local/libexec/imapd
imapd pop3s stream tcp nowait root /usr/local/libexec/ipop3d ipop3d
- imaps stream tcp nowait root /usr/local/libexec/imapd
- Restart inetd.
- /etc/rc.d/inetd restart
Testing
At this point it should just work. I test with Mozilla Thunderbird 1.5 and with Microsoft Outlook Express. Both worked fine but you have to remember to enable SSL.