Set up the local MTA on the web server machine (b) so that it uses your main SMTP relay (a) as its "smart host". Consult the documentation for your mail transfer software as to how to do that.
PHP will send mail using the local MTA, which will in turn deliver it, via SMTP, to the "smart host" (unless locally addressed, which it won't be in most cases), which will then send it on to its destination.
At both stages it will be queued if the route ahead is unavailable.
Mark