Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP编译器和端口问题_Php_Phpmailer - Fatal编程技术网

PHP编译器和端口问题

PHP编译器和端口问题,php,phpmailer,Php,Phpmailer,更新:我已经设法找到了问题的解决方案,之前问过。一切似乎都正常,没有显示错误,但我没有收到电子邮件 端口465是开放的,我可以远程登录它。 根据我在stackoverflow上找到的建议,我尝试检查SMTP服务器日志记录,但在安装IIS以启用日志记录后,我的Apache服务器停止工作->我尝试更改端口,但没有帮助。我被卡住了 <?php require 'PHPmailer\class.phpmailer.php'; $mail = new PHPMailer;

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

端口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();
 }
    }

}


    ?>

感谢您的帮助

它显示电子邮件已发送的消息,因为您不检查是否已发送任何电子邮件。如果我没记错的话,
$mail->Send()
应返回已发送电子邮件的数量,如果返回0,则应检查错误。关于phpmailer中错误的更多信息:抱歉,这是旧代码,我现在将首先编辑它,使用phpmailer,无需在
php.ini
中设置SMTP服务器。另外,在创建
$mail->From
$mail->FromName
$mail->Body
时,请删除单引号或使用双引号。此外,缺少
$mail->Subject
。Alt最后,检查防火墙端口465中的传出连接。谢谢,我会试试。防火墙修复了所有问题,并在php.ini中发现了一个端口错误。现在一切似乎都正常(没有错误),但电子邮件没有发送。。
     smtp_port = 465;
     auth_username = test@gmail.com
     auth_password = test
     sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"