Moodle version? Server operating system?
Is the moodle server on the very same machine as the imap server?
nmap -P0 -p 143 localhost
or
nmap -P0 -p 993 localhost
There are 4 options to the type of IMAP in a 2.3 version of Moodle:
imap, imapssl, imapcert, imaptls.
Which will your server 'talk'?
Do the imap accounts already exist?
In IMAP config in Moodle:
You can lock user data fields. This is useful for sites where the user data is maintained by the administrators manually by editing user records or uploading using the 'Upload users' facility. If you are locking fields that are required by Moodle, make sure that you provide that data when creating user accounts or the accounts will be unusable.
Consider setting the lock mode to 'Unlocked if empty' to avoid this problem.
'spirit of sharing', Ken