If you are using postfix, you could try this:
Create this file:
echo "firstname.lastname@example.org email@example.com
" >> /etc/postfix/sender_canonical
Next, run the following commands:
postconf -e "sender_canonical_maps=hash:/etc/postfix/sender_canonical"
Finally, restart postfix
Try to send mail and post results here.
This will change www-data for no-reply, but it will work for every site in the same way...
If you want to have a different behavior per site, you must declare a path por sendmail in php.ini, create a script to intercept mail, validate from direction, if it is "www..." you must consult which domain is seding mail (I don't know is the are available variables for this in sendmail, but I think you can get path of file sending mail and with that get the sender domain) and as a final step, replace to "from" of the mail.