?
Solved

PHP mail() function not working

Posted on 2003-02-28
6
Medium Priority
?
295 Views
Last Modified: 2007-12-19
I'm experiencing a strange situation on my FreeBSD web server. About two months ago when I first set it up, I tested PHP's mail() function, and it worked fine. Recently, when I tried to impliment a script that used it, it wouldn't work. No error message is given in reply, and I'm having a tough time figuring out where in the world to start. I'm far from a sendmail/unix expert. The sendmail daemon is running, and I've tried restarting it with no effect. The performance of the script doesn't change whether it's running or not (never gives an error message). Any ideas on what I could try to diagnose the problem?

-Jeff
0
Comment
Question by:jeffers
[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 Comments
 
LVL 3

Accepted Solution

by:
NetWize earned 300 total points
ID: 8043566
Have you checked the sendmail-logs for errors? Maybe the local delivery works and it's a general SMTP-Problem?

Have you tried sending mail from shell (with "mail user@host.com") command?
0
 
LVL 2

Expert Comment

by:tconnolly
ID: 8043568
I had a similar problem where I was hosting several sites with a host, and on one site, the php mail() function worked and on another, it didn't. The only discrepancy I could find between the different servers was the version of PHP. The server with 4.2.2 worked but the ones (i tried more than one) with 4.2.3 did not. I can only imagine it had something to do with configuration or the upgrade when installed, but just a couple of pennies for ya.

Hope this helps :)
Tom Connolly
0
 

Expert Comment

by:spanky302
ID: 8044312
Hey jeffers,

Also check your php.ini file for your sendmail path.
You can also find this via the phpinfo() function.

E
0
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 

Author Comment

by:jeffers
ID: 8044855
I tried to use "mail user@host.com", and at the end I get the following error, which I also get using the sendmail command directly:

can not chdir(/var/spool/clientmqueue/): Permission denied
Program mode requires special privileges, e.g., root or TrustedUser.

lrwxrwxrwx  1 root   wheel .. /usr/sbin/sendmail -> /usr/sbin/mailwrapper
-r-xr-xr-x  1 root   smmsp .. /usr/sbin/mailwrapper
drwxrwxrwx  2 smmsp  smmsp .. /var/spool/clientmqueue

I found some about this on google, and it said to set sendmail's GID to smmsp, but didn't mention that sendmail was a link. I tried setting the link's GID, but it just stays "wheel". I did change mailwrapper's GID to smmsp, but that had no effect on the error message.
0
 
LVL 1

Expert Comment

by:tenacious
ID: 8045216
One of the criticisms I voice over and over again is that minor releases of PHP result in seemingly needless changes to APIs and functionality.  Often these changes are undocumented and developers don't see problems until they take a working code set to a different version of PHP.  I've experienced major headaches when I upgraded PHP from 4.0.2 to 4.1.1 on a server with running applications.  Or even worse going from 4.1.3 to 4.2.1.  In some cases parameter lists of established functions actually change.

I experienced problems with sendmail() on a windows environment.  If attachments were >3889 bytes the sendmail() function would just crash the process, not producing any error.  I would see no error log messages, nothing in the SMTP server, and nothing on the browser (nor an e-mail).  After taking apart the _source code_ for PHP i noticed the sendmail() function had some code written just for windows that limited the size of the header parameter to 4K bytes.  That seemed to be the culprit, it was reproduced, and hopefully it's been fixed (but I don't know).  After many tries at different workarounds I ended up just writing the RSC-compliant text to a file and then called a DOS program to send that file as e-mail.  There are third-party products that I could've bought as an alternative and used within PHP much like sendmail() - but I didn't have the money...
0
 

Author Comment

by:jeffers
ID: 8046907
I finally resolved the problem with the following:

cd /usr/src/etc && make DESTDIR=/ distrib-dirs

Thanks everybody for the tips that helped me find the solution.
0

Featured Post

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

764 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