Web Gateway is an HTTP Proxy, it does accept and forward eMails. When your software talks to an external mail server using port 25 this traffic should not be intercepted on MWG so if you have MWG configured as a proxy or deployed transparently your application should still be able to talk to the external mailserver on port 25.
Probably I did not correctly understand the question. In this case maybe you can give an example.
In what mode is configurated your WG?? if its proxy or bridge, you don't had to worry about trafic on port 25