0

I am trying to send mail in php, it returns true but the mail is not delivered.

$To = $email;
$Sub = "Reset Password";
$Msg = "Please click on the given link or copy url to reset your password<br/>";
$Msg .= "mydomain/password_reset.php?Note=".$random_note."&uid=".$c_id."&email=".$email;
$Header = "MIME-Version: 1.0" . "\r\n";
$Header .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 
$Header .= 'From: Admin <admin mail>' . "\r\n";

if (mail($To,$Sub,$Msg,$Header))
      {
         echo "Please confirm your email to reset your password<br/>";
         echo "Email temporarily Displayed here</br>".$Msg;
          exit();
      }
NewDeveloper
  • 105
  • 3
  • 12
  • Assuming you are running a Linux machine, can you check the logs (via: tail -f /var/log/mail.log) and post what you find. – HomerPlata Jun 01 '17 at 09:32
  • no, i am not using linux – NewDeveloper Jun 01 '17 at 09:33
  • Check your server configuration if you're even able to send mails. "Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination." http://php.net/manual/en/function.mail.php - Also check your spam folder. – Twinfriends Jun 01 '17 at 09:34
  • @NewDeveloper Oh. Well, still try to find your mail.log and post the contents here. – HomerPlata Jun 01 '17 at 10:01

1 Answers1

0

The php mail() function has some issues in general. It usually ends up in spam folders because of unset headers etc.

After a couple of days of fiddling myself I came across this gem: PHPMailer

I'd advice you to look into using a library like this. This will probably also solve your issue if it is code related.

superstienos
  • 124
  • 11