我想用他们的用户名向新注册用户发送确认电子邮件我有代码并且所有详细信息都插入到 mysql 数据库中我正在处理它但它不会向注册用户发送电子邮件
<?php
$email=$_SESSION['email'];
if(!$_SESSION['email'] || $_SESSION['email']){
header('Location:login.php');
}
if(isset($_REQUEST['signup'])){
$signup=$_POST['signup'];
$username=$_POST['username'];
$password=$_POST['password'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$gender=$_POST['gender'];
$datepicker=$_POST['datepicker'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$address=$_POST['address'];
$country=$_POST['country'];
$city=$_POST['city'];
$validemail = eregi("^[a-z0-9_-]+(\.[a-z0-9_-]+)*@([a-z0-9_-]+\.)*[a-z0-9_-]+\.[a-z]{2,}$", $email); //VALID EMAIL PATTERN
//CHECKS IF ALL FIELDS HAVE BEEN FILLED
if($username&&$password&&$fname&&$lname){
//CHECKS IF EMAIL IS VALID
if($validemail){
$q = mysql_query("SELECT * FROM customers WHERE email='$email'");
$r = mysql_fetch_assoc($q);
$n = mysql_num_rows($q);
//CHECKS IF EMAIL ALREADY EXISTS IN THE DATABASE
if(!$n){
$q = mysql_query("SELECT * FROM customers WHERE username='$username'");
$r = mysql_fetch_assoc($q);
$n = mysql_num_rows($q);
//CHECKS IF USERNAME ALREADY EXISTS IN THE DATABASE
if(!$n){
//CHECKS IF THE PASSWORD AND CONFIRMATION PASSWORD MATCH
if($password){
//IF ALL CONDITIONS ARE TRUE, THE USER IS REGISTERED AND AN ACTIVATION KEY IS PROCESSED AND SENT VIA EMAIL
$alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$length = 11;
for($i=0; $i<$length; $i++){
$ran = rand(0, strlen($alpha)-1);
$key .= substr($alpha, $ran, 1);
}
//SENDS EMAIL THAT TELLS THE USER TO ACTIVATE THE ACCOUNT
$activation = 'activation.php?key='.$key;
$your_email = 'non-reply@mydomain.com'; //CHANGE TO YOUR SETTINGS
$domain = $_SERVER["HTTP_HOST"]; //YOUR DOMAIN AND EXTENSION
$to = $email;
$subject = 'Activate Account';
$message = 'Welcome, '.$_POST['username'].'. You must activate your account via this message to log in. Click the following link to do so: http://'.$domain.'/'.$activation;
$headers = 'From: My Domain <'.$your_email.'@'.$domain.'>\r\n'; //MODIFY TO YOUR SETTINGS
$headers .= 'Content-type: text/html\r\n';
mail($to, $subject, $message, $headers);
}
}}}}
$sqlquery=mysql_query("INSERT INTO customers VALUE('','$username','$password','$fname','$lname',
'$gender','$datepicker','$email','$phone','$address','$country','$city','','$key','')")or die("Error");
if ($sqlquery)
{
header('location:index.php?id=signup-confirmation');
}
else {
header('location:signup.php');
}
}
?>