LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 07-02-2008, 06:08 PM   #1
twlilinux
Member
 
Registered: Jan 2006
Distribution: debian
Posts: 63

Rep: Reputation: 15
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.

Last edited by twlilinux; 08-15-2008 at 04:31 PM.
 
Old 07-02-2008, 06:42 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
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.
 
Old 07-02-2008, 08:51 PM   #3
twlilinux
Member
 
Registered: Jan 2006
Distribution: debian
Posts: 63

Original Poster
Rep: Reputation: 15
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.

Last edited by twlilinux; 08-15-2008 at 04:31 PM.
 
Old 07-02-2008, 09:01 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
I'm sure there is. I don't know exim; I use postfix. Hopefully, someone with exim experience will chime in...
 
Old 07-02-2008, 11:28 PM   #5
twlilinux
Member
 
Registered: Jan 2006
Distribution: debian
Posts: 63

Original Poster
Rep: Reputation: 15
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.

Last edited by twlilinux; 08-15-2008 at 04:32 PM.
 
Old 07-02-2008, 11:51 PM   #6
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
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
 
Old 07-03-2008, 10:16 PM   #7
twlilinux
Member
 
Registered: Jan 2006
Distribution: debian
Posts: 63

Original Poster
Rep: Reputation: 15
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.

Last edited by twlilinux; 08-15-2008 at 04:32 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Root Mail bsd-mailx parent's_basement Debian 1 06-06-2008 05:26 PM
Regarding mailing to a distribution list (DL) using mail/mailx command naren_0101bits Programming 0 02-06-2008 10:33 AM
php mail() not working sajith Programming 2 11-30-2006 11:54 AM
mail(mailx) to be nullclient? Chowroc Linux - Networking 0 12-18-2004 06:17 AM
Composing and sending HTML mail from mailx stv_t Solaris / OpenSolaris 2 03-15-2004 04:23 PM


All times are GMT -5. The time now is 11:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration