Specify smtp server for php mail() in freebsd?
Question
I have two dedicated servers, one of which is configured for sending email out (SPF, DKIM, other domain whitelisting methods, etc). I need to send email from both servers, but I want to send mail from both servers through the server that's been set up for it.
It doesn't look like I can explicitly set an SMTP server directly in the mail function. Is there a way I can override the value set in php.ini, through .htaccess or something?
Solution
I would recommend not using the mail
command and using a pre-built PHP mailing solution. There are 2 great recommendations at the following: Is this the correct way to send email with PHP?
In using a pre-built solution, you can have all of your mail go to the same server if you choose.
OTHER TIPS
I would recommend using ezcMail for sending emails. It has a clean object oriented prebuilt mailing package which is highly configurable.