Table of Contents
1. Install Courier
apt-get install courier-imap This will pull down all relevant packages Chose defaults when installing. No to web-based administration. Ok to default cert. (see more later)
2. Main Config is naturly enough in /etc/courier Nothing is chanced in Courier Configs 3. To get postfix handing off to Courier:
Config Postfix (done using this page: http://www.samba.netfirms.com/courier/courier.html) /etc/postfix/main.cnf Comment out #mailbox_command = /user/bin/... Include or uncomment home_mailbox = Maildir/
4. Step 3 should automatically make a Maildir in /home/user when mail is recieved
If you want to make the maildir manually, because a maildir is required for IMAP Login: Done using this website: http://archives.free.net.ph/message/20050807.151155.5ecafcf2.en.html /home/user maildirmake Maildir This can be done for defauly users in the skeleton account /etc/skel/
5. IMAP login and receiving emails should work ok using telnet (see postfix_smtp for info on sending email with telnet)
6. Fix for courier.
So thunderbird gave me the error: “Alert from account: Filesystem notification initialization error – contact your mail administrator (check for configuration errors with the FAM/Gamin library).
apt-get install gamin
Ref: http://zeldor.biz/2010/12/fix-filesystem-notification-initialization-error/ http://www.tutorialnut.com/index.php/2010/05/18/quick-fix-filesystem-notification-initialization-error-contact-your-mail-administrator-check-for-configuration-errors-with-the-famgamin-library/
7. Now there does seem to be a load in PROCMAIL that I'm not using.
Rules can be made as to what folder to sort incoming email.
(Some basics are at: http://www.pocock.com.au/linux-doc/mbox-maildir.html)
Actually I am mixing up procmail with maildir!!
POSTFIX → PROCMAIL (not even sure!) → MAILDIR → COURIER
Install and Config for Procmail
apt-get install procmail vi /etc/postfix/main.cf #add the line: mailbox_command = /usr/bin/procmail -a "$EXTENSION" DEFAULT=$HOME/Maildir/ MAILDIR=$HOME/Maildir restart postfix and test.
Quick config for procmail
vi /home/$USER/.procmailrc #Start of Procmailrc script. PATH=/bin:/usr/bin:/usr/bin MAILDIR=$HOME/Maildir LOGFILE=$MAILDIR/procmail.log :0 c !firstname.lastname@example.org
This above procmail recipe creates a procmail log for the user. It also forwards a copy of all email to email@example.com More procmail rules at http://wiki.kartbuilding.net/index.php/Procmail
===== Update Cert =====
Even though I'm sure its not the best practice, I copy the newly updated apache.pem cert and use it for courier-ssl.
cp /etc/apache2/ssl/apache2.pem /etc/courier/imapd.pem
Mandate secure imapds
vi /etc/courier/imapd-ssl IMAP_TLS_REQUIRED=1
On installing courier via apt-get it creates a test ssl cert. However its not self-signed. To create a self-signed cert:
cd /root/ openssl req -x509 -newkey rsa:1024 -keyout imapd.pem -out imapd.pem -days 9999 -nodes #rename /etc/courier/imapd.pem to -old #move from /root into /etc/courier chown courier /etc/courier/imapd.pem chmod 600 /etc/courier/imapd.pem /etc/init.d/postfix restart /etc/init.d/courier-imap-ssl restart
Testing imaps via a client PC and problems
Testing with thunderbird did not go to plan. I normally use thunderbird portable to login and test. It hung and did not create the account. In /var/log/mail.info, it showed: imapd-ssl: ip=[::ffff:], Certificate is bad
After a lot of testing, it turned out it was nothing to do with imapd.pem, but a problem with thunderbird and self-signed certs. Thunderbird did not prompt to allow exception.
Solution 1 - Use Mailbird - it prompted to allow and store exception.
Solution 2 - Fix for Thunderbird for imaps self-signed certs:
go to Options > Composition > Addressing Check Directory server and Edit Directories > Add new set name to: 'fakeLdapDirectory' specify server address: mail.mydomain.com Base DN: cn=base Check 'Use secure connection(SSL)' set port: 993 Bind DN: cn=user,cn=base Base and Bind DN does not need to exist, cn=user,cn=base will doe the trick. Click OK, close Edit connections dialog. Select directory server in the list Go to Inbox Tab > Address Book Select fakeLdapDirectory in the list and type something into the search input on top right. If asked for password type anything e.g. 'letMeIn' You should get 'confirm certificate exception dialog', confirm it, now mail messages should be downloadable
For final additions to postfix with courier and procmail, please see: debian_bullseye_config