LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-12-2008, 01:08 PM   #1
JavaNinja
Member
 
Registered: Sep 2008
Posts: 90

Rep: Reputation: 15
Sendmail - PHP not working with it


Hello all,

I have asked this in a PHP forum, but I think I have identified the problem to be more related to sendmail not accepting PHP to send emails.

I migrated to a new server (Fedora 9) everything works fine but sending mail via php. In my php.ini:
Code:
sendmail_from	no value	no value
sendmail_path	/usr/sbin/sendmail -t -i	/usr/sbin/sendmail -t -i
Path to sendmail 	/usr/sbin/sendmail -t -i
Sendmail works fine since I can send mail from it like so:
Code:
[root@localhost] echo "Test" | mail -s "Sup Dude" myemail@googlemail.com
But the mail function in PHP always failes!

Is there something I need to do to connect PHP and sendmail?

Really need help on this!

Thanks all
 
Old 12-12-2008, 01:08 PM   #2
JavaNinja
Member
 
Registered: Sep 2008
Posts: 90

Original Poster
Rep: Reputation: 15
According to /var/log/maillog:
Code:
Dec 12 17:59:46 localhost sendmail[2345]: NOQUEUE: SYSERR(apache): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied
So apache isn't allowed to view the configuration for sendmail, is it fine just to open permission to all?

Should apache be added to the trusted users list of sendmail?
 
Old 12-12-2008, 01:53 PM   #3
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
No don't open up the permissions. That problem looks like the it is in your php.ini. I will see if I can find something. I remember coming across a document with similar problems but had a solution.
 
Old 12-12-2008, 01:57 PM   #4
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
try just using /usr/sbin/sendmail. See what results that yeilds. After change you may have to reload apache. you may have to give read access to the sendmail.cf file though.
 
Old 12-12-2008, 02:47 PM   #5
JavaNinja
Member
 
Registered: Sep 2008
Posts: 90

Original Poster
Rep: Reputation: 15
Hey jstephens84,

Thank you for your reply. I changed the php.ini file and restarted apache with the change you suggested but I still can't send emails from the php mail function, always returns false. And the log has the same thing in it:
Code:
Dec 12 21:45:44 localhost sendmail[2526]: NOQUEUE: SYSERR(apache): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied
Here are the permissions for sendmail.cf:
Code:
-rw-r--r-- 1 root root 58624 2008-03-29 12:27 sendmail.cf
-rw-r--r-- 1 root root  7205 2008-03-29 12:27 sendmail.mc
What else can I try?

Thanks
 
Old 12-12-2008, 03:58 PM   #6
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Try checking to see if you have selinux turned on. If you do then it may be blocking the access to that service. look in grub.conf and see if you see anything like selinux=0 or 1

0 = permissive mode
1 = enforcement mode

you can also check at /boot/grub/grub.conf

FC 3 and above uses selinux by default unless you turn it off during startup.
 
Old 12-12-2008, 04:29 PM   #7
JavaNinja
Member
 
Registered: Sep 2008
Posts: 90

Original Poster
Rep: Reputation: 15
There was nothing in grub.conf??

But when I type sestatus i get:
Code:
[root@localhost ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 23
Policy from config file:        targeted
CRAP! How do I change the following to on?
Code:
[root@localhost ~]# sestatus -b | grep sendmail
httpd_can_sendmail  off
 
Old 12-12-2008, 04:39 PM   #8
JavaNinja
Member
 
Registered: Sep 2008
Posts: 90

Original Poster
Rep: Reputation: 15
I changed it and a lot of other things, restarted sendmail and httpd and no difference! HELP!
Code:
httpd_builtin_scripting              on
httpd_can_network_connect            on
httpd_can_network_connect_db         on
httpd_can_network_relay              on
httpd_can_sendmail                   on
httpd_enable_cgi                     on
httpd_enable_ftp_server              off
httpd_enable_homedirs                on
httpd_execmem                        off
httpd_ssi_exec                       off
httpd_tty_comm                       on
httpd_unified                        on
httpd_use_cifs                       off
httpd_use_nfs                        off
 
Old 12-12-2008, 06:25 PM   #9
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
This is going to sound crazy but try a reboot. Not sure if you have done that yet but lets just humor ourselves for a moment. We may also want to fully turn SElinux off. Can't help much as I am not a big fan of SE so I always just turned it off. So I have little to no experience with it.
 
Old 12-13-2008, 08:42 AM   #10
JavaNinja
Member
 
Registered: Sep 2008
Posts: 90

Original Poster
Rep: Reputation: 15
This is really getting me down now!

I have rebooted switched off SElinux and put it in permissive mode too and tried to send emails which still doesn't work!

Why not add apache user to the allowed users list?

Are these settings ok?
Code:
[root@localhost ~]# sestatus -b | grep httpd
allow_httpd_anon_write               off
allow_httpd_dbus_avahi               off
allow_httpd_mod_auth_ntlm_winbind    off
allow_httpd_mod_auth_pam             off
allow_httpd_sys_script_anon_write    off
httpd_builtin_scripting              on
httpd_can_network_connect            on
httpd_can_network_connect_db         on
httpd_can_network_relay              on
httpd_can_sendmail                   on
httpd_enable_cgi                     on
httpd_enable_ftp_server              off
httpd_enable_homedirs                on
httpd_execmem                        off
httpd_ssi_exec                       off
httpd_tty_comm                       on
httpd_unified                        on
httpd_use_cifs                       off
httpd_use_nfs                        off
 
Old 12-13-2008, 01:33 PM   #11
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Adding apache to the allowd user list should be fine. Earlier I thought you meant changing say the permissions of the sendmail.cf file to 777. That was my fault.
 
Old 12-13-2008, 02:34 PM   #12
JavaNinja
Member
 
Registered: Sep 2008
Posts: 90

Original Poster
Rep: Reputation: 15
I could cry! Apache is already in the trusted users list!
Code:
# trusted-users - users that can send mail as others without a warning
# apache, mailman, majordomo, uucp, are good candidates
Although when I look at the mailog, I tried it send an email and I get:
Code:
Dec 13 21:32:17 localhost sendmail[7488]: mBDLWHNk007488: from=apache, size=61, class=0, nrcpts=0, msgid=<200812132132.mBDLWHNk007488@localhost.localdomain>, relay=apache@localhost
It use to deny it like this:
Code:
Dec 12 21:45:44 localhost sendmail[2526]: NOQUEUE: SYSERR(apache): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied
I am not even sure what I have changed?!

Btw, jstephens84 - thank you for sticking with me in resolving the issue and before YOU are right, I did mean changing the permissions of the sendmail.cf file. :P
 
Old 12-13-2008, 05:03 PM   #13
jstephens84
Senior Member
 
Registered: Sep 2004
Location: Nashville
Distribution: Manjaro, RHEL, CentOS
Posts: 2,098

Rep: Reputation: 102Reputation: 102
Well that is good to see that it works now. Too bad we don't know how we fixed it so someone else could benefit but oh well. That is how it goes sometimes. It works and you have no clue how it started.
 
Old 12-13-2008, 05:24 PM   #14
JavaNinja
Member
 
Registered: Sep 2008
Posts: 90

Original Poster
Rep: Reputation: 15
I know, I wish I knew what was going on, but a slight problem :P There is no email in my inbox and the mail function still returns false even though the maillog seems to suggest its fine!

Code:
Dec 14 00:18:01 localhost sendmail[2856]: mBE0I1QT002856:
 from=apache, size=189, class=0, nrcpts=0, msgid=
<200812140018.mBE0I1QT002856@localhost.localdomain>,
 relay=apache@localhost
Really sorry this dragging on, but why do you think this is?

Is there another mailserver I can setup and use to see if its any different. I am so weary of sendmail!
 
Old 12-13-2008, 05:34 PM   #15
JavaNinja
Member
 
Registered: Sep 2008
Posts: 90

Original Poster
Rep: Reputation: 15
WAIT! IT WORKS - I change the php.ini back to "/usr/lib/sendmail -t -i" and it sent. OH MY GOD!

Thank you so much for helping me and sticking with me jstephens84!! I bet I get this problem in the future and I won't know what to do - but I will be back here for sure!
 
  


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
Changing port in sendmail, sendmail not working. flschou Linux - Newbie 4 01-16-2008 09:03 AM
sendmail is not working & on $prompt the cmd sendmail hangs Pavan mahoorker Linux - Software 1 04-04-2006 03:57 PM
php+ sendmail no good - python + sendmail ok nephish Linux - Networking 1 10-07-2005 01:19 PM
PHP and sendmail lost@sea Linux - Software 5 09-21-2005 09:16 AM
php and sendmail akamaru607 Linux - Newbie 1 08-25-2005 12:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:08 AM.

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
Open Source Consulting | Domain Registration