在PHP中注册后发送给用户欢迎电子邮件


send to the user welcome email after registration in php

我试图在注册后向用户发送欢迎消息,但它没有向电子邮件发送任何内容,但数据已插入数据库你能帮我弄清楚我的代码有什么问题吗

 $email = $_POST['email'];    
 $query2 = mysql_query("INSERT INTO facultymember (pin,ID,firstname,midname,lastname,phone,email,password,Door_Num) Values('".$_POST["type"]."','".$_POST["FMID"]."','".$_POST["firstname"]."','".$_POST["middlename"]."','".$_POST["lastname"]."','".$_POST["phone"]."','".$_POST["email"]."','".$_POST["password"]."','".$_POST["Door_NUM"]."')", $connection);
     $message = "Add Successfully";
if($query2)
{
$subject = "Email Verification mail";
$headers = "From: email@domain.com 'r'n";
$emessage = "welcome";
mail($email,$subject,$emessage,$headers);
}

试试下面的代码:

$to      = $email; // Send email to our user
$subject = "Email Verification mail"; // Give the email a subject 
$emessage = "welcome";
// if emessage is more than 70 chars
$emessage = wordwrap($emessage, 70, "'r'n");
// Our emessage above including the link
$headers   = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: no-reply <noreply@yourdomain.com>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion(); // Set from headers
mail($to, $subject, $emessage, implode("'r'n", $headers));