One of our domains has had problems with emails from their php code being bounced by some servers and then sent to the wrong return email address.
The attached is a php function that tries to set all the neccessary email addresses. If you are writing your own php code then this may be of use. I'm storing it here for future use.