Php sendmail error in centos 6.5


#1

Hi

I have problem with sending mail from php application, please check my below config files

checkmail.php

<?php ini_set('display_errors', 1); set_include_path('/usr/share/pear/'); // set_include_path('/usr/share/php5/PEAR/'); require_once('System.php'); $to = 'testuser@gmail.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: localhost' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?>

php.ini
sendmail_path = /usr/sbin/sendmail.postfix -t -i

/var/log/httpd/error_log
sendmail.postfix: fatal: chdir /var/spool/postfix: Permission denied

SELINUX - Enforcing
setsebool -P httpd_can_sendmail 1

Still getting same from "sendmail.postfix: fatal: chdir /var/spool/postfix: Permission denied
"


#2

I have checked the postfix error log

fatal: scan_dir_push: open directory defer: Permission denied


#3

[root@localhost spool]# grep TrustedUser /etc/mail/*cf
/etc/mail/sendmail.cf:#O TrustedUser=root
/etc/mail/submit.cf:O TrustedUser=smmsp

anyone pls help ???


#4

open your script in vi editor

step1: vi checkmail.php

step2 set: fileformat=unix

step3 wq


#5

Use Perl! Best Regards. :wink:
########################
#!/usr/bin/perl
use strict;
use warnings;

first, create your message

use Email::MIME;
my $message = Email::MIME->create(
header_str => [
From => ‘_yourmail@xxx.com’,
To => ‘receiver@xxx.com’,
Subject => ‘yoursubject’,
],
attributes => {
encoding => ‘quoted-printable’,
charset => ‘ISO-8859-1’,
},
body_str => “Your_message\n”,
);

send the message

use Email::Sender::Simple qw(sendmail);
sendmail($message);