所以我建立了自己的网站,试图使用github中的phpmailer 5.2版本创建电子邮件验证。 我的代码是正确的,但是我没有收到任何邮件(那里没有错误) 如果有人可以帮助我,我将很高兴
<?php
$conn= new mysqli('localhost','root','','up');
mysqli_query($conn,"SET NAMES 'utf8'");
if($conn->connect_error){
exit('Cannot connect');
}
else{
$button='';
if((isset($_POST["username"]))||(isset($_POST["fullname"]))||(isset($_POST["password"]))||(isset($_POST["email"]))||(isset($_POST["gender"]))||(isset($_POST["vkey"]))){
$username=$_POST['username'];
$fullname=$_POST['fullname'];
$password=$_POST['password'];
$email=$_POST['email'];
$gender= $_POST['gender'];
$vkey=md5(time().$username);//verification code always changes according to the compuechos time zone
$password=md5($password);
$sql="INSERT INTO signup (Username,Fullname,Password,Email,Gender,`Vkey`) VALUES ('$username','$fullname','$password','$email','$gender','$vkey')";
if($conn->query($sql)){
require_once('PHPMailer/PHPMailerAutoload.php');
$mail= new PHPMailer(true);
$mail->isSMTP();
$mail->PHPAuth= true;
$mail->SMTPSecure='tls';
$mail->Host='smtp.gmail.com';
$mail->Port=25;
$mail->isHTML(true);
$mail->Username='my email';
$mail->Password='my pass';
$mail->SetFrom=('my email');
$mail->Subject='hello';
$mail->Body='hello';
$mail->Send();
echo "<script>alert('משתמש נוצר בהצלחה נא לגשת לתיבת המייל לצורך אימות')</script>";
}
}
}
?>