@alan
As hufemj already said, it is much easier to test & troubleshoot in TB (especially when you are new to IMAP).
This is the variable in the conf file, that needs to be set to "true" when you login the first time and didn't create the user in your database manually:
$rcmail_config['auto_create_user'] = true;