0

更新:我已经设法找到问题的解决方案,之前问过。一切似乎都正常,没有显示错误,但我没有收到电子邮件

端口 465 已打开,我可以远程登录它。根据我在 stackoverflow 上找到的建议,我尝试检查 SMTP 服务器日志记录,但在安装 IIS 以启用日志记录后,我的 Apache 服务器停止工作-> 我尝试更改端口,但没有帮助。我被困...

  <?php
   require 'PHPmailer\class.phpmailer.php';
   $mail = new PHPMailer;

      $mail->IsSMTP();                                      
      $mail->Port = 465;
      $mail->Host = 'smtp.gmail.com';  
      $mail->SMTPAuth = true;                               
      $mail->Username = 'test@gmail.com';                            
      $mail->Password = 'test';                           
      $mail->SMTPSecure = 'ssl';                             
  if (!empty($_GET)){
   $errors=array();
$email = isset($_GET['email']) ? $_GET['email'] : '';
$name = isset($_GET['name']) ? $_GET['name'] : '';
$message = isset($_GET['message']) ? $_GET['message'] : '';
if (empty($name) || empty($email) || empty($message)){
$errors[]='All fields are required!';
}else{
    if (!filter_var("$email", FILTER_VALIDATE_EMAIL)){
        $errors[]='The email is not valid!';
    }
}
if (empty($errors)){
$mail->From = $email;
$mail->FromName = $name;
$mail->IsHTML(true);                                 
$mail->Body    = $message;
$mail->Subject ="From IMDB";
$mail->IsHTML(true);                                  
$result = $mail->Send();
   if(!$result) {

       echo $mail->ErrorInfo; 
   } else {
 header('Location:contactForm.php?sent');
 exit();
 }
    }

}


    ?>

我也会附上一段 php.ini:

     smtp_port = 465;
     auth_username = test@gmail.com
     auth_password = test
     sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

感谢帮助

4

0 回答 0