我正在尝试在用户注册到此表单后向我的电子邮件地址(管理员)发送电子邮件确认!请问如何配置我的sendmail?我正在使用Xampp。代码正常,消息
显示电子邮件已发送
但是当打开包含在$to
变量中的电子邮件地址时,收件箱中没有任何电子邮件。这是我的代码:
<html >
<head>
<title></title>
</head>
<body>
<?php
print ("<form action='register.php' method='post'>
<p>Name
<input type='text' name='firstname' />
</p>
<p>Surname
<input type='text' name='lastname' />
</p>
<p>Username
<input type='text' name='username' />
</p>
<p>Password
<input type='password' name='password' />
</p>
<p>Email <input type='text' name='email'/> </p>
Enter your CV: <p> <textarea name='cv' cols='60' rows='50'></textarea> </p>
<input type='submit' value='Register'/>
</form>
");
if( !($database=mysql_connect("localhost","root",""))||!(mysql_select_db("st_login",$database)) )
print("Could not connect");
if(isset($_POST['firstname'] )&&isset($_POST['lastname'])&&isset($_POST['username'])&&isset($_POST['password'])
&&isset($_POST['cv'])/*&&isset($_POST['notat'])&&isset($_POST['lendet'])*/&&isset($_POST['email'])){
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$username=$_POST['username'];
$password=$_POST['password'];
$email=$_POST['email'];
$cv=$_POST['cv'];
/*
$notat=$_POST['notat'];
$lendet=$_POST['lendet'];
*/
$query = "INSERT INTO login (firstname, lastname, username,password,cv,email) VALUES ('$firstname', '$lastname',
'$username','$password','$cv','$email')";
}
if ( !empty($firstname)&&!empty($lastname)&&!empty($username) &&!empty($password)&&!empty($cv)&&!empty($email))
{
if(!($result=mysql_query($query,$database)))
{
print("Could not execute query");
die (mysql_error());//ose error
}
$to='backa.elda123@gmail.com';
$subject='Asking for permission';
$body='There is another registered student waiting for your approval!';
$headers='From:<arbi.backa@gmail.com>';
if(mail($to,$subject,$body,$headers)){
echo "mail sent to..";}
else echo'errorr sending the email';
echo "YOU HAVE BEEN REGISTERED SUCCESSFULLY!PLEASE WAIT FOR THE ADMIN APPROVAL!";
}
else echo "Fill in all the blank fields";
mysql_close($database);
?>
</body>
</html>