If you use mail()
in PHP, the documentation states that it only uses sendmail on the local machine.
You may, however, setup sendmail to forward mail to your other server, like in this link : http://www.cyberciti.biz/faq/configure-sendmail-as-a-smart-host/
According to that page, you can do this:
Add to /etc/mail/sendmail.mc
:
define(`SMART_HOST',`my_smtp_server')
Then restart sendmail. If it still doesn't work, you might need to run:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
or
cd /etc/mail; make
and then restart sendmail.
If you need to fake the server name which sendmail uses, you might add this in sendmail.nc (ref.: https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-email-mta-sendmail.html):
FEATURE(always_add_domain)
FEATURE(`masquerade_entire_domain')
FEATURE(`masquerade_envelope')
FEATURE(`allmasquerade')
MASQUERADE_AS(`my_public_domain.')
MASQUERADE_DOMAIN(`my_public_domain.')
MASQUERADE_AS(my_public_domain)