Re: mail() on *nix using ssmtp or an external smtp server?
| From: | Markus Mayer | Date: | Wed, 18 Aug 2004 15:30:56 +0000 |
| Subject: | Re: mail() on *nix using ssmtp or an external smtp server? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194157@lists.php.net to get a copy of this message | ||
I've been trying further to get ssmtp working with apache/php in a chrooted
envrionment and have had some success on Linux, so I'm sharing it with
everyone else. I've also come to understand quite well how the mail()
function is implemented in php too, and actually it's quite simple.
All directories that I speak of below are relative to the new root directory
in the chrooted environment.
First thing is ssmtp expects to find its config files in /etc/ssmtp/, so that
needs to be created inside the chrooted environment. The real killer for
this whole thing however, and seemingly where everything was falling over, is
that I had to put ssmtp in the /usr/sbin/ directory. For reasons that
totally illude me, if ssmtp is in the /bin directory or anywhere else, mail()
fails!?!?! The php.ini file needs to be in the usual /usr/local/lib/
location, and the sendmail parameter in the php.ini file needs to be set to
"/usr/sbin/ssmtp -t". Do not try any other flags, otherwise mail() fails.
The attempts I've made today have brought results and are reproducible. This
also works in a normal (that is not chrooted) environment.
The demanded location of the ssmtp binary is by far the most bizarre thing I
have had in this whole exercise, and I would appreciate it if someone else
might be able to take the time to confirm my findings. What I also don't
understand is that if I have ssmtp in the /bin directory (or anywhere else
for that matter) and invoke it from the command line in a chrooted
environment, it works happily. It also worked happily when I wrote my own
short C program that emulated what is done in the PHP mail delivery
procedures. For what ever reason, it just refused to work through PHP if it
was anywhere other than /usr/sbin/ssmtp.
So ssmtp in a chrooted environment, provided it's in /usr/sbin/, works well on
a Linux box, but on AIX machines, it still fails completely and I don't yet
know why. As I have done this time, if I have any success, I will post to
the list so other people can know. If anyone else has some success with this
on AIX, I would greatly appreciate knowing about it.
best regards
Markus