PHP mail() function output true no email received

Viewed 22

im trying to send email using mail() directly without third party library. What i've done so far is configured the headers got it from google and reading question here in stackoverflow.

<?php

if (isset($_POST['submit'])) {
  $to = "fariho9303@nicoimg.com"; // temp email from temp-mail.org
  $from = $_POST['email']; // this is the sender's Email address
  $name = $_POST['name'];
  $subject = "Form submission";
  $message = $name . " wrote the following:" . "\n\n" . $_POST['message'];

  $headers = "From:" . $name . '<' . $from . '>' . PHP_EOL;
  $headers .= "Reply-To:" . $to . PHP_EOL;
  $headers .= "MIME-Version 1.0" . PHP_EOL;
  $headers .= "Content-Type: text/html; charset=UTF-8" . PHP_EOL;
  $headers .= "X-Mailer: PHP/" . phpversion();
  $status = mail($to, $subject, $message, $headers);

  echo "<pre>";
  var_dump($status);
  if ($status) {
    echo '<p>Your mail has been sent!</p>';
  } else {
    echo '<p>Something went wrong. Please try again!</p>';
  }
}
?>

I got it running by installing send mail in my ubuntu https://stackoverflow.com/a/46386409

Then i print var_dump to see the result. This outputs true and message sent. But im not receiving any message in my email. enter image description here

Dont know what im missing here. Any help would be greatly appreciated

0 Answers
Related