0

Pls Guide Simple code here is not sending mail. The following Code is returning False and not returning any error message. I have already done the needful setting in PHP.ini and sendmail.ini.

<?php  

    $to = "husainsalik@gmail.com";
    $subject = "Test subject";
    $body = "Test Body";
    $header = 'husainsalik@gmail.com';
    

    $send = mail($to, $subject, $body, $header);

    if($send)
    {
        echo "Mail Sent √";
    }
    else
    {
        echo "Mail Failed"; 
    }

?>   

The above code is returning Mail Failed.

KIKO Software
  • 15,283
  • 3
  • 18
  • 33
Husain
  • 21
  • 3
  • 1
    There are a lot of potential problems. Email is actually quite a complex business. See here: [PHP mail function doesn't complete sending of e-mail](https://stackoverflow.com/questions/24644436/php-mail-function-doesnt-complete-sending-of-e-mail) – ADyson Dec 18 '20 at 10:54
  • 1
    This question has been asked many times on Stack Overflow. The short answer is: Don't use GMail to test a mail server. GMail doesn't know your mail server, and will block any emails from it. Start by looking into SPF and DKIM. See also: https://support.google.com/a/topic/9061731 – KIKO Software Dec 18 '20 at 10:55

0 Answers0