Your imap server needs to support impersonation. Dovecot does this, maybe others as well. http://wiki2.dovecot.org/Authentication/MasterUsers