1

I'm trying to send to the user welcome message after registration, but it did not send anything to the email, but the data is inserted in the database can you please help me figure out what is wrong with my code

 $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 protected] \r\n";
$emessage = "welcome";
mail($email,$subject,$emessage,$headers);
}
Afnan Humdan
  • 195
  • 3
  • 12

1 Answers1

0

Try this code below:

$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 <[email protected]>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion(); // Set from headers

mail($to, $subject, $emessage, implode("\r\n", $headers));
halfer
  • 19,824
  • 17
  • 99
  • 186
shafiul
  • 14
  • 3