1

I have the following PHP script to test mail() functionality:

<?php
    echo `whoami`;
    error_reporting(E_ALL);
    ini_set('display_errors', '1');

    $name = 'John';
    $email = 'j@example.com';
    $message = 'My message';
    $verify = '4';
    $to = 'youremailaddress@somedomain.com';
    $subject = 'Enquiry';
    $headers = 'From: j@example.com' . "\r\n" .
                            'Reply-To: j@example.com' . "\r\n" .
                            'MIME-Version: 1.0' . "\r\n" .
                            'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
                            'X-Mailer: PHP/' . phpversion();

    if (1 == 1)
    {
            if (mail($to, $subject, $message, $headers))
            {
                    echo '<p>Sucess</p>';
            }
            else
            {
                    echo '<p>Something went wrong</p>';
            }
    }
    else
    {
            echo '<p>Submit not clicked</p>';
    }
?>

Upon accessing the page I receive no errors, the output in the log file is as follows:

[20-Jan-2017 00:07:25 America/New_York] mail() on [/var/www/html/contact/contact.php:20]: To: youremailaddress@somedomain.com -- Headers: From: j@example.com  Reply-To: j@example.com  MIME-Version: 1.0  Content-type: text/html; charset=iso-8859-1  X-Mailer: PHP/5.6.29-0+deb8u1

The script appears to execute correctly but I do not receive any email.

hermetik
  • 115
  • 9
  • are you trying it on your localhost? – Nishant Nair Jan 20 '17 at 05:15
  • For sending mail through localhost you can use PHPMailer – NITIN PATEL Jan 20 '17 at 05:19
  • all a successfully call to mail tells you is the local MTA accepted the mail, there are several dozen reasons why it may not arrive at its destination: http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail –  Jan 20 '17 at 05:28

1 Answers1

0

put your mail sending logic inside try{} catch(e){ console.log(e) } . So that you will come to know about error

user2724057
  • 49
  • 1
  • 5