$ret = mail($to, $subject, $body, $headers); if ($ret) { echo "sent\n"; } else { echo "failed with code $ret\n"; } echo "done\n" I am trying to invoke this via apache, the call to mail fails immediately, and there is no return value, and so, I am stuck. Can you please point me in the right direction to debug this ? Thanks much
mail() returns either true of false, and echoing false won't give you any output. But the mail() function should trigger an error if it fails. If you don't see it, your error reporting is probably set to hide errors or warnings. Try this. error_reporting(E_ALL); ini_set('display_errors', '1'); echo mail($to, $subject, $body, $headers) ? 'sent' : 'failed'; PHP:
Thanks for your reply. It still displays no error at all. Any idea why that would be the case? Thanks.