unable to send mail via php and ssmtp -
there no errors in code can find , local ssmpt client configured , can send mail via command line. no mail , no error come php @ all. it's though php never hits local mailer. 'do' have sendmail path set in php.ini , restarted apache. don't know else be?
<?php require_once('config.php'); $attrs = array(pdo::attr_persistent => true); $pdo = new pdo("mysql:host=localhost;dbname=".$dbname, $db_username, $db_password, $attrs); $pdo->setattribute(pdo::attr_errmode, pdo::errmode_exception); $custlist = $pdo->prepare("select customer_list.sms_num, carriers.carrieraddr, customer_list.contact_first, customer_list.contact_last carriers, customer_list send_id=send_code order customer_list.sms_num"); #$carrierlist = $pdo->prepare("select * carriers"); if (isset($_post['body'], $custlist)) { $custlist->execute(); #var_dump($custlist); #var_dump($_post['body']); while ($row = $custlist->fetch(pdo::fetch_assoc)) { #$prefix = $row['sms_num']; #$suffix = $row['carrieraddr']; $to = 'brads@telecomm.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'from: admin@telecomm.com' . "\r\n" . 'reply-to: admin@telecomm.com' . "\r\n" . 'x-mailer: php/' . phpversion(); mail($to, $subject, $message, $headers); #$body = $_post['body']; #var_dump($prefix); #var_dump($suffix); #var_dump($_post['body']); } } //$products = array(); $smscustobject = new arrayobject($custlist); #$smsarrayobject = new arrayobject($carrierlist); $pdo = null; ?> <form action="" method="post"> message body <input name="body" type="text" /> <input type="submit"> </form>
i had same problem , found after running port testing php script needed configure linux (centos in case) allow httpd access tcp ports using following command on command line:
setsebool httpd_can_network_connect=1
or permanently
setsebool -p httpd_can_network_connect=1
nb: using -p option took on 2 minutes on machine patient
hey presto! mail command worked.
my situation was able send mail isp's smtp server ie mail.optusnet.com.au port 25 command line not using php scripts ran in browser.
also, ensure firewall not interfering php running telnet session smtp host.
eg $telnet mail.optusnet.com.au 25
in case suspect not able send emails command line.
i hope helps
Comments
Post a Comment