I’m using the sendmail package and php, When I try to use the mail function in PHP it returns true but nothing is sent.
php config
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path =/usr/sbin/sendmail -t -i
php file
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);
trace(mail('jamie@domain.tld','Testing','test.'));
the mailer log is displaying this
mail() on [/var/www/misc/mail.php:5]: To: jamie@domain.tld -- Headers:
Running sendmail through the CLI as this:
echo -e "To: jamie@domain.tld\nSubject: Test\nTest\n" | sendmail -bm -t -v
Returns “Sender ok”, “Recipient ok”
Anyone know of anything which could be causing php to not send the email?
PHP has nothing to do with mail delivery. Its job begins and ends with handing the email off to the specified SMTP agent/server. If
mail()does not return a boolean FALSE, then PHP’s job has succeeded and it’s out of the picture.Check your SMTP server’s logs to see what happens to the email after the handoff is completed. It’s quite likely the mail is being rejected/greylisted/spamfiltered into oblivion, because PHP’s
mail()truly blows.Consider switching to either Swiftmailer or PHPMailer, both of which offer far better diagnostics of the PHP<->SMTP interactions than mail() ever will.
Testing manually from the command line means little: your shell environment is very different from the in-webserver environment that your script is likely executing in – apples and oranges.