You don't understand: I would need to change PHP! In other words, I would need to edit the C code which implements PHP's IMAP support. I can do it (I know C), but first of all the code is ugly (personal opinion) and second of all, I would have to repatch that every time a new version of PHP came out (if I had to install it do get a security fix). This is not code that would interest anybody else (since the authentication method is specific to us), so open source and/or sending patches upstream don't help.