Re: [PHP] mail command failing
On Tue, 2010-06-29 at 10:27 -0700, Mike Wright wrote: > Ashley Sheridan wrote: > > On Tue, 2010-06-29 at 10:00 -0700, Mike Wright wrote: > > > >> Hi all, > >> > >> I'm very puzzled by this. I've been using the php mail command for > >> years but now I can't get it to work and can't figure out how to > >> diagnose the problem. > >> > >> > >> php-5.2.29 on fedora10 with apache 2.2.14. Can this be selinux related? > >> > > > > The first ini_set variable you're setting I believe will only work for a > > Windows server. > > > > Aside from that, yes SELinux does prevent the mail command from sending > > mail by default. I'm using Fedora 11, so I assume it will be similar; > > there are config tools for setting SELinux policies, or you could even > > turn it off (not advised on a live server). As a test, try turning it > > off temporarily just to see if it is the culprit, then you can determine > > what policy changes need to be made. > > > > Thanks, Ash, but no cigar. Selinux is set disabled. Absolutely baffled > and confounded that there doesn't seem to be a way to diagnose the problem. > > Mike > I can only guess that PHP somehow isn't seeing the sendmail program for some reason. Have you compared the output of a phpinfo() call on this system and another where it is working to see if there are any obvious differences in the server setups? Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] mail command failing
From: Ashley Sheridan > On Tue, 2010-06-29 at 10:00 -0700, Mike Wright wrote: > >> Hi all, >> >> I'm very puzzled by this. I've been using the php mail command for >> years but now I can't get it to work and can't figure out how to >> diagnose the problem. >> >> The code below was copied from the manual (addresses changed, etc); >> php.ini has safe_mode off; binary is at /usr/sbin/sendmail. >> >> > ini_set("SMTP","localhost" ); >> ini_set('sendmail_from', 'mike.wri...@mailinator.com'); >> >> $name = "Mike Wright"; //senders name >> $email = "mike.wri...@mailinator.com"; //senders e-mail adress >> $recipient = "mike.wri...@mailinator.com"; //recipient >> $body = "The text for the mail..."; //mail body >> $subject = "Subject for review"; //subject >> $header = "From: $name <$email>\r\n"; //optional headerfields >> >> $echo = mail($recipient, $subject, $body, $header) ? 'success':'fail'; >> echo "$echo"; >> >> I can access the mail server with "/usr/bin/mailx" and by telnet >> "localhost 25". I can also send mail using php by using 'exec (" echo >> $body | mailx -s $subject $recipient")'. >> >> php-5.2.29 on fedora10 with apache 2.2.14. Can this be selinux related? >> >> Any ideas or troubleshooting tips? > > > The first ini_set variable you're setting I believe will > only work for a Windows server. > > Aside from that, yes SELinux does prevent the mail command from sending > mail by default. I'm using Fedora 11, so I assume it will be similar; > there are config tools for setting SELinux policies, or you could even > turn it off (not advised on a live server). As a test, try turning it > off temporarily just to see if it is the culprit, then you can determine > what policy changes need to be made. Don't turn it off, set it for Permissive mode. It will both allow the connection and log why it wouldn't allow it in normal operation. Then you can review the logs and make the necessary adjustments. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail command failing
Ashley Sheridan wrote: On Tue, 2010-06-29 at 10:00 -0700, Mike Wright wrote: Hi all, I'm very puzzled by this. I've been using the php mail command for years but now I can't get it to work and can't figure out how to diagnose the problem. php-5.2.29 on fedora10 with apache 2.2.14. Can this be selinux related? The first ini_set variable you're setting I believe will only work for a Windows server. Aside from that, yes SELinux does prevent the mail command from sending mail by default. I'm using Fedora 11, so I assume it will be similar; there are config tools for setting SELinux policies, or you could even turn it off (not advised on a live server). As a test, try turning it off temporarily just to see if it is the culprit, then you can determine what policy changes need to be made. Thanks, Ash, but no cigar. Selinux is set disabled. Absolutely baffled and confounded that there doesn't seem to be a way to diagnose the problem. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail command failing
On Tue, 2010-06-29 at 10:00 -0700, Mike Wright wrote: > Hi all, > > I'm very puzzled by this. I've been using the php mail command for > years but now I can't get it to work and can't figure out how to > diagnose the problem. > > The code below was copied from the manual (addresses changed, etc); > php.ini has safe_mode off; binary is at /usr/sbin/sendmail. > > ini_set("SMTP","localhost" ); > ini_set('sendmail_from', 'mike.wri...@mailinator.com'); > > $name = "Mike Wright"; //senders name > $email = "mike.wri...@mailinator.com"; //senders e-mail adress > $recipient = "mike.wri...@mailinator.com"; //recipient > $body = "The text for the mail..."; //mail body > $subject = "Subject for review"; //subject > $header = "From: $name <$email>\r\n"; //optional headerfields > > $echo = mail($recipient, $subject, $body, $header) ? 'success':'fail'; > echo "$echo"; > > I can access the mail server with "/usr/bin/mailx" and by telnet > "localhost 25". I can also send mail using php by using 'exec (" echo > $body | mailx -s $subject $recipient")'. > > php-5.2.29 on fedora10 with apache 2.2.14. Can this be selinux related? > > Any ideas or troubleshooting tips? > > Thanks, > Mike Wright > The first ini_set variable you're setting I believe will only work for a Windows server. Aside from that, yes SELinux does prevent the mail command from sending mail by default. I'm using Fedora 11, so I assume it will be similar; there are config tools for setting SELinux policies, or you could even turn it off (not advised on a live server). As a test, try turning it off temporarily just to see if it is the culprit, then you can determine what policy changes need to be made. Thanks, Ash http://www.ashleysheridan.co.uk