0

I'm trying to send a email to user after successfully register. So that following is my .php code.

$to = $email;                       
$subject = "Signup | Verification";
$message = "Congratulation $f_name $l_name you have been successfully registered. Please 
click the link to active your account.\r\n";
$message .= "http://www.maaks.fr/hotel/verify.php?email=$email&hash=$hash\r\n";

$from = "[email protected]";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-rype: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding; 7bit\r\n";
$headers = "From:" . $from . "\r\n";

$sentmail = mail($to,$subject,$message,$headers);                   
if($sentmail)
{
header("Location: thankyou.php?member=successfully");
exit();
}

It doesn't sent a email to the user. I checked it that if $sentmail is ok then It's go thankyou page. But interesting matter is that it's go to thankyou page without sent a email.

Is there anything i forgot?

1
  • the mail function doesn't return true when the mail is send. It returns true when your mail has been given to your mail delivery system, whichever one that is. Meaning that the return value you get doesn't say that it has been send, but that the send procedure has started. Commented Nov 27, 2012 at 9:49

2 Answers 2

3

The mail() function returns true if the message was accepted for delivery, it doesn't mean the message will be delivered.

From the Manual:

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.

Your message is probably being blocked by the recipients spam filter or going straight to the junk folder.

Sign up to request clarification or add additional context in comments.

4 Comments

I checked it but can't find any email. Can you tell me what's the possible cause?
Try different recipients from different email providers, try gmail, hotmail, yahoo etc etc to see if any get through.
It's almost certainly being blocked as spam because the keyword Congratulation along with a link looks very spammy.
try running it at home on your local machine, install XAMPP or some equivalent and send your email message via localhost to a localhost email adress. Bypasses spam filters etc, then you can check whether it is a spam filter or that your code is not working. On top of that you can easily see your mail server logs allowing your to do some more digging!
0

There is one minor typo in your email message but I don't think it will solve your problem.

You have a Content-rype specified, you should change that to Content-type...

But again I don't think that will solve your problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.