0

Here is my PHP code fragment. I would provide more code if Necessary.

if (mail($to, $subject, $message, $header)) {
  echo 'I can send the mail!';
  return true;
}

The body of $message is like this. In case that can be the problem:

$email      = $_POST['email'];
$email      = $connection->real_escape_string($email);
$to      = $email;
$subject = "Reset your password";
$header  = "from: Site <contact@demosite.com>";
$message = "Hi, ".$username."! You or someone else used this email address to reset password for Site. If you did not do it ignore the message.\n";
$message .= "To reset your password please click on the link below\n";
$url = 'http://demosite.com/reset.php?rkey=' . $rkey . '';
$message .= $url;

Both the register and reset function have similar text except for the fact that registered uses $code instead of $rkey.

I can echo I can send the mail so the function returns true. Why am I still unable to receive any emails. Are there some other reasons that could cause this?

This is not related to window 8, I can't send the mail from my hosting provider and they use Linux. Could anyone remove the duplicate tag?

SanJeet Singh
  • 1,291
  • 2
  • 15
  • 28
  • No prob in your code. check this [Can't send email with php mail](http://stackoverflow.com/questions/30610387/cant-send-email-with-php-mail-function-on-windows-8/30610643#30610643) – Abdulla Nilam Dec 09 '15 at 15:36
  • Did you check your spam folder? everything looks fine – yardie Dec 09 '15 at 15:36
  • Yes, I checked the spam folder. There is nothing in there. Surprising thing is exact same code works in another function. The only difference is that of the text. – SanJeet Singh Dec 09 '15 at 15:37

0 Answers0