Probably the database had to be filled. I edited all domains and it starts working.
But now I get a 404 error, I guess that's the IMAP failure bug.
Would it be hard to edit the script to add support for courier IMAP and Dovecot?
In the original script the lines which have to be edited are given. But I'm not nearly as good in scripting as you are, but I do want to help!