I am attempting to use PEAR to send email on a Fedora server machine and am getting nowhere.
Below is the code I am trying to use. The email authentication settings in the code are not the actual but the info I am using is pulled from my email client config so should work.
I am also trying to get debug info to find out what is happening. Is setting 'debug' to 'true' enough or is something else required? And where can I find the debug log information?
A lot of asks but I hope someone can direct me in the right direction.
I tried PHPMailer as well but no go. I have this sense that some configuration on the machine is blocking...
One more thing, this exact code works on a Ubuntu machine so I know it works. I am trying to move all services from the Ubuntu machine to a Fedora machine.
require_once "Mail.php";
$from = "demo@demo.com";
$recipients = 'demo@demo.com';
$headers["From"] = $from;
$headers["To"] = 'demo@demo.com';
$headers["Reply-To"] = $from;
$headers["Subject"] = 'Testing';
$headers["MIME-Version"] = "1.0";
$headers["Content-Type"] = "text/html; charset=UTF-8";
$body = 'Testing';
$smtpinfo["host"] = "mail.demo.com";
$smtpinfo["port"] = "587";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "demo@demo.com";
$smtpinfo["password"] = "password";
$smtpinfo["debug"] = true;
$mail_object = Mail::factory("smtp", $smtpinfo);
$mail_object->send($recipients, $headers, $body);
if (PEAR::isError($mail_object)) {
$ret['success'] = false;
$ret['msg'] = 'Message delivery failed...';
} else {
$ret['success'] = true;
$ret['msg'] = 'data is valid';
}
return $ret;
?>
Thank you
Answer
So, after a few more hours of testing I have resolved the issue. This website provided direction on how to get debug information in the command line.
After testing the PHP code from the command line and confirming that messages can be sent, I attempted to send an email from a web page; which failed to work.
So, now thinking that the issue is likely related to the web server, led me to this question on . The solution of which resolved the issue immediately. Specifically, doing the following as described in the accepted solution:
$ sestatus -b | grep sendmail
httpd_can_sendmail off
$ restorecon /usr/bin/sendmail
$ setsebool -P httpd_can_sendmail 1
Hope this helps someone else facing the some problem.
No comments:
Post a Comment