This is a simple script for moving email from one inbox to another. I can't guarantee everything works right, but the basics are there.
See the Exchange Web Services for PHP project for some notes on how to configure the mail server. Once you set that up, simply change the exchange and gmail inforation to your own and run the sync (note that it will delete your exchange email, so be careful).