Possible Duplicate:
How to configure php.ini with remote SMTP?
We have a php application running on Linux which sends emails to there users. Currently its setup like php.ini is configured to send via local sendmail server but we have separate mail server for our organization for this domain. I want to send the php application emails via that remote smtp server so these emails can have the correct SPF records and sign via DKIM.
But I could not see such option in php.ini to specify the remote host address to forward emails to that, its for windows only.
I saw some post which suggest phpMailer
but I could not find how to configure that so all our php application could send via our remote SMTP.
Please search first, this was asked before (e.g. in How to configure php.ini with remote SMTP?).
The PHP
mail()
function always uses sendmail (on Linux/Unix). There is no way to change that by php.ini. That leaves two other means:mail()
function with calls to an alternative library (e.g. PHPMailer).sendmail
command) to do the right thing, i.e. set the domain's mail server as a smarthost.I would install nullmailer and configure it to forward emails to your relay server. The linux distribution that you are using most likely has nullmailer packages, so that a sendmail binary (that is command line compatible) is installed in the proper place.
If you do not want to install nullmailer, it is possible to do with sendmail too. If you want, I will update the answer.
UPDATE:
If you want to do this under sendmail, you have a number of choices:
(1) In sendmail.mc define the SMART_HOST to be your mail relay server:
(2) You can use FEATURE(nullclient).
(3) Modify rule set 0 to do this. In sendmail.mc add the following lines:
Do not copy-paste the code snippet above since the left hand side is separated from the right hand side with tabs and not spaces.
After you are done editing sendmail.mc you need to compile sendmail.cf and restart sendmail. In Debian this is done by running
sendmailconfig
. In CentOS this is done by running/etc/mail/make
followed byservice sendmail restart
.