I have the following code in sendmail.php:
#!/usr/bin/php
<?php
$to = "testmail@gmail.com";
$subject = "TestSubject";
$body = "TestBody";
if (mail($to, $subject, $body)){
echo "Mail Sent";
}else {
echo "Mail Failed";
}
?>
If I visit the web pathtothefile/sendmail.php it sends the mail OK. but if i make in a shell:
chmod 755 sendmail.php
./sendmail.php
It says "Mail Sent" but nothing is sent. Why is that happening? Thanks