daker
daker

Reputation: 3540

How to get php mail() to work?

My script.php

<?php
ini_set('display_errors', 1); 
error_reporting(E_ALL);

$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

$res = mail($to, $subject, $message, $headers);
var_dump($res);
?>

php.ini essentials

sendmail_path = /usr/sbin/sendmail -t -i
mail.log = /home/myuser/phpmail.log

How do I get it to work? What can i do to debug?

Upvotes: 1

Views: 533

Answers (2)

daker
daker

Reputation: 3540

This finally worked

Opened port 25 for localhost in iptables and removing the "i" from sendmail_path in php.ini

sendmail_path = /usr/sbin/sendmail -t

Upvotes: 0

AnFi
AnFi

Reputation: 10913

0) Check sendmail log files

1) Send a test message as the same system user

#!/bin/sh
/usr/sbin/sendmail -v -t -i <<END
To: [email protected]
Subject: the subject
From: [email protected]
Reply-To: [email protected]

hello
END
echo SENDMAIL EXIT CODE: $?

Upvotes: 1

Related Questions