mail command failing
| From: | Mike Wright | Date: | Tue, 29 Jun 2010 17:00:25 +0000 |
| Subject: | mail command failing | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-306522@lists.php.net to get a copy of this message | ||
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.
<?php
ini_set("SMTP","localhost" );
ini_set('sendmail_from', 'mike.wright@mailinator.com');
$name = "Mike Wright"; //senders name
$email = "mike.wright@mailinator.com"; //senders e-mail adress
$recipient = "mike.wright@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 "<br/><br/>$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