LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   php mail() not working but mailx works (http://www.linuxquestions.org/questions/linux-server-73/php-mail-not-working-but-mailx-works-653185/)

twlilinux 07-02-2008 05:08 PM

php mail() not working but mailx works
 
My mailx works fine. I can send mails from the command line. However the php mail() function doesn't work.

I suspect that the php mail() is trying to send as root. How do I find out what user php is currently trying to send mail as. And, anyone knows how to make the php send mail as a user other than root?

Thanks in advance!

-------
My favorite websites:
Buy and sell class notes, old exams, papers, lab reports, admission essays.
Ask and answer Linux questions.
Read free books without walking to the library.

Mr. C. 07-02-2008 05:42 PM

php's mail on non-windows' systems uses the sendmail binary. Check your mail logs, ensure you have Sendmail, Postix or other equivalent MTA. The mail() function allows additional parameters, such as sendmail's -f to set the enveloper sender.

twlilinux 07-02-2008 07:51 PM

my sendmail binary is exim4. Is there a .conf file somewhere where I can tell it to send mail as nonroot?

Also, anyone knows what's all this in my exim log file?
2008-07-02 17:43:19 Start queue run: pid=27486
2008-07-02 17:43:19 End queue run: pid=27486
2008-07-02 18:13:19 Start queue run: pid=27678
2008-07-02 18:13:19 End queue run: pid=27678
2008-07-02 18:43:19 Start queue run: pid=27702
2008-07-02 18:43:19 End queue run: pid=27702
2008-07-02 19:13:19 Start queue run: pid=27723
....etc

-------
My favorite websites:
Buy and sell class notes, old exams, papers, lab reports, admission essays.
Ask and answer Linux questions.
Read free books without walking to the library.

Mr. C. 07-02-2008 08:01 PM

I'm sure there is. I don't know exim; I use postfix. Hopefully, someone with exim experience will chime in...

twlilinux 07-02-2008 10:28 PM

Yeah.. please chime in lol. I'm out of cards here. I even tried changing the ownership of the php script to a normal user, but still no luck.

-------
My favorite websites:
Buy and sell class notes, old exams, papers, lab reports, admission essays.
Ask and answer Linux questions.
Read free books without walking to the library.

Mr. C. 07-02-2008 10:51 PM

My advice, if you are going to select and user a mailer (MTA: such as exim, postfix, sendmail), your going to need to know how to diagnose problems and understand what to look for in a mail transaction.

Check your php.ini file to ensure that sendmail_path is correct, and you can also set mail.force_extra_parameters to -f "root@yourdomain.com"

sendmail_path = /usr/sbin/sendmail -t -i

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters = -f root@mydomain.com

twlilinux 07-03-2008 09:16 PM

Well, I have it working now... but have absolutely no idea what I did. It's strange because exim4 isn't even running or showing up in netstat. But still, it's working.

For anyone who is having a similar problem, here's what I can remember what I did:

make sure exim4 is configured to be able to directly send mail
sendmail_path = /usr/sbin/sendmail -t -i -f me@mydomain.com
check the PID of exim4, then kill it.

If you're lucky like me, php should be now able to sendmail. Cheers.

-------
My favorite websites:
Buy and sell class notes, old exams, papers, lab reports, admission essays.
Ask and answer Linux questions.
Read free books without walking to the library.


All times are GMT -5. The time now is 01:28 PM.