So, let's start from the first step...
Before anything else, you should open courier-imap and courier-pop3 configuration files (on my system, /etc/courier/imapd and /etc/courier/pop3d).
Look for a line like
AUTHMODULES="authdaemon"
or
AUTHMODULES="any_fancy_authentication_module"
and change it in
AUTHMODULES="authdaemon authmkhome"
or
AUTHMODULES="any_fancy_authentication_module authmkhome"
Beware! authmkhome relies on other modules authenticating the users. Thus, it must
be called as the last authentication module (unless you want to see funny things happening to
your system).
Watch out that once courier is configured to use authmkhome, any authenticated user whose home directory does not exist won't be allowed in in case authmkhome can't find a valid maildir-creator script.