In an attempt to send mails from a php script, I am testing the mail() function with this code:
<?php
ini_set("display_errors", "1");
error_reporting(E_ALL);
$to = 'example@gmail.com';
$message = 'test';
$from = 'test@gmail.com';
$subject = 'Test';
$headers = "From: $from\n";
mail($to, $subject, $message, $headers) or die ("Message not sent");
?>
This is not the only code I have tried it with, but nothing seems to be working. One of the reasons I am inquiring here is because it returns no errors whatsoever. I get no indication of any error at all, except that the mail never reaches it's destination. Things that I have done to try and fix the problem:
- Changed the SMTP in php.ini from localhost to gmail's smtp
- Checked spam filters and outboxes on both ends
- Tried various methods of error reporting
- Tried several different functions for sending mail
- Checked seemingly related things in phpinfo() and looked them up to no avail
I think it may be an issue with the sendmail function in my terminal, but I have no way to test or fix any issues related to the sendmail function.
I am running apache 2.0 on a PPC Mac with OS X 10.4 Tiger and PHP 5.3.12.