jeffers
asked on
PHP mail() function not working
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
-Jeff
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hey jeffers,
Also check your php.ini file for your sendmail path.
You can also find this via the phpinfo() function.
E
Also check your php.ini file for your sendmail path.
You can also find this via the phpinfo() function.
E
ASKER
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/clientmqu eue/): 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.
can not chdir(/var/spool/clientmqu
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.
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...
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...
ASKER
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.
cd /usr/src/etc && make DESTDIR=/ distrib-dirs
Thanks everybody for the tips that helped me find the solution.
Hope this helps :)
Tom Connolly