you have to set the permissions in ISA, this is not all related to anything regarding PHP. That is a rule problem.
Grant incoming access to the IMAP port in ISA from what ever server you are running the webmail client on. This should solve your problem. I would also create a port 80 incoming access rule that allows those connections from the server the client is on as well.
Hope that helps. BTW buy a $100.00 pentium 3 crap computer, put fedora, suse, debian or madrake on it and use shorewall as ur firewall. Its easier to configure and a lot more trust worthly then ISA.