Forum Moderators: bakedjake

Message Too Old, No Replies

Problem with sendmail in PHP chrooted environment

...but works in perl

         

rpking

11:43 am on Mar 18, 2003 (gmt 0)

10+ Year Member



I'm working on a PHP script that needs to send emails, on a FreeBSD machine in a chrooted environment.

I have tried various methods to send the mail from PHP, starting with the basic mail() function, and now I've tried using sendmail.

The code is basically:

1 $fp = popen('/path/to/sendmail -t','w');
2 fputs($fp,"To: $to\n");
3 fputs($fp,"From: $from\n");
4 fputs($fp,"Subject: $subject\n\n");
5 fputs($fp,"$body");
6 pclose($fp);

This returns no errors in PHP, but no mail is sent. I've checked that a file handler is returned on line 1, and characters are written on lines 2 to 5.

I don't know too much about chroot but I understand that problems such as this can arise i.e. modules are not copied across to the new environment and so cannot be accessed.

What I don't understand is why a virtually identical script using perl in the same environment actually send mails.

Can anybody enlighten me as to what the problem might be?

David

2:39 pm on Mar 18, 2003 (gmt 0)

10+ Year Member



Have you checked to see if the sendmail_path: has been set in the php.ini file?

The mail() function should be the way to do it.

nosanity

8:39 am on Mar 19, 2003 (gmt 0)

10+ Year Member



You could always write your own mailer function that will use smtp to send out e-mail. This way you can also check which smtp server to use based on the domain name of the end address, and send it directly to them.

noSanity