Solved

PHP "MAIL" Function not sending mail - RH7 - Apache - PHP4

Posted on 2002-03-07
14
255 Views
Last Modified: 2006-11-17
This is probably a very simple problem, but I have tried several "canned" scripts that seem to work, up to the point that you SUBMIT the form stuff. Everything works, I just don't get any mail!

Something like:
mail("$adminaddress","Info Request", "FAO: Admin @
...
Date/Time:  $date","FROM:$adminaddress");

Found no clues in the MAILLOG file.

I CAN send mail from the prompt.

Any ideas welcome...
0
Comment
Question by:victorus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 4

Expert Comment

by:heddesheimer
ID: 6849809
I think some providers have disabled the mail function especially on free webspace. When you say you have console access, it seems very unlikely that this is the case in your situation.

Have you asked your provider if they may have disabled the mail function for some reason? Some providers do that to prevent spam from their accounts.

An alternative would be to call the sendmail program with a system() or exec() command directly. So if you can do it from the console prompt, it should also work within PHP.

Marian
0
 
LVL 4

Expert Comment

by:heddesheimer
ID: 6849816
if you run your own server, this might be helpful:

http://hotwired.lycos.com/webmonkey/00/44/index4a_page11.html?tw=programming

Maybe there is a linie missing in your php.ini regarding your mail program. So search this article for "mail()" to find out what you should enter in php.ini

Marian
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6849903
mail function's working is dependent on your php.ini setting.

You would have following in your php.ini

[mail function]
; For Win32 only.
SMTP = localhost

; For Win32 only.
sendmail_from = me@phpkid.org

; For Unix only.  You may supply arguments as well (default: 'sendmail -t -i').
;sendmail_path =


Which platform you are on ?
If you are on *nix, set sendmail path, if on windows set up SMTP to correct SMTP server.

Incase its not possible for you to edit php.ini, You can use phpmailer from http://phpmailer.sourceforge.net. It would allow you to use any SMTP server, even the one who needs pop authentication before use. I highly recommend it.

JD
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:victorus
ID: 6855702
I followed dkjariwala's advise (For Unix only:) since I am running Red Hat Linux 7.0 on my own server and the same server runs SENDMAIL. Still same results! I use POP5 daemon for the mail send / receive. SENDMAIL does not require authentication. Made changes and rebooted, if that was your next question. Here is that part of my PHP.INI...

[mail function]
;SMTP     =  localhost               ;for win32 only
;sendmail_from     =  me@localhost.com     ;for win32 only
sendmail_path     = /usr/sbin/sendmail -t -i

Any ideas?
0
 
LVL 5

Accepted Solution

by:
dkjariwala earned 100 total points
ID: 6855769
You don't need that -t -i switch.

Try with that again,
Also make sure that sendmail is configured on your machine.

Once you have used the mail() function, check your mail queue by mailq command through shell.

Regards,
JD
0
 

Expert Comment

by:colemanchow
ID: 6856103
Hi all,

  I am a php newbie.
  I would like to ask how can I check I have installed the sendmail program? If this progrma is absent, how can I install this?

Thx a lot!!!
0
 
LVL 4

Author Comment

by:victorus
ID: 6856991
JD's last comment got me into really probing around. I made the suggested change to no avail. MAILQ shows nothing in the queue. BUT Apache log file ERROR_LOG shows:

sh: /usr/sbin/sendmail: Permission denied

Ok. Where to go now???

-Vic
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6857040
I guess that says everything.

Does the user nobody ( user apache runs as ) have permission to call up sendmail ???

JD
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6857045
I guess that says everything.

Does the user nobody ( user apache runs as ) have permission to call up sendmail ???

JD
0
 
LVL 4

Author Comment

by:victorus
ID: 6857583
User APACHE is running the HTTPD. APACHE has the /bin/false shell. Do I need to give it a real shell like /bin/bash, to run SENDMAIL? Is that safe to do, security speaking?
0
 
LVL 4

Author Comment

by:victorus
ID: 6858130
User APACHE is running the HTTPD. APACHE has the /bin/false shell. Do I need to give it a real shell like /bin/bash, to run SENDMAIL? Is that safe to do, security speaking?
0
 
LVL 4

Author Comment

by:victorus
ID: 6882622
Tried changing APACHE shell to /bin/bash but still getting "sh: /usr/sbin/sendmail: Permission denied". Where are APACHE permissions to use SENDMAIL? How can I test?
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6883132
Which group user *Apache* belongs to ?
What are the permissions for /usr/sbin/sendmail ??

JD
0
 
LVL 4

Author Comment

by:victorus
ID: 6910307
My last post disappeared! Anyway, dkjariwala is the one on track here, so I am going to award him the answer points. It is obvious that I am having trouble with something other than PHP stuff. I cannot add a user on this machine that has ANY rights, except that of mail and FTP access. So it is obvious that Apache user would not have SENDMAIL rights. Even ROOT is acting strange as seen by the fact that LS is giving me some strange results like;

ls *.conf   [gives me]
sh: -c: line 1: unexpected EOF

and normal users at the console:
[at login]
bash: id: command not found

ls  [gives me]
sh: /usr/lib/ldlibls.so: Permission Denied

So, I will post this in the General Linux forum for more info. I might just re-build this server if it becomes a major proble. Thanks for all of the help.

-Vic
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question