You don't need a "bounce back email script"; you need to find out why your email isn't being sent.
The reason your server cannot send email from a Yahoo / GMail address to another Yahoo / GMail address is that your local server is not a Yahoo / GMail server. Unless you send the email through their servers, using proper authentication, they will reject the message as "spoofed".
It's as if a random person has walked up to the front door of your office, claimed to be from your internal IT department, and demanded to inspect your servers. Since you know they're
not from your IT department, you wouldn't let them in.
To send email from a Yahoo or GMail address, you need to own that address. You will then be able to authenticate to the Yahoo / GMail mail server, and send the message via that server.
Depending on your setup, you might need to use an alternative email library. For example:
PHPMailer - A full-featured email creation and transfer class for PHP[
^]
Send Mail through GMail SMTP Server with PHP[
^]