PHP Mailer没有';无法在我的服务器上发送邮件且未加载错误

PHP Mailer没有';无法在我的服务器上发送邮件且未加载错误,php,phpmailer,Php,Phpmailer,我正在使用PHP MAiler,但邮件没有被发送,事实上,我服务器上的网站一直在加载,没有显示任何错误。我甚至更改了我的gmail设置,允许使用不太安全的应用程序,但页面仍然没有加载,也没有显示任何错误。 代码: 我的Php mailer文件夹与此文件夹位于同一文件夹中,因此我想加载文件不是问题您能否验证电子邮件是否未发送或未收到?这是有区别的。可能会对您有所帮助。首先,尝试使用您的凭据连接并配置另一个smtp客户端(theBat、outlook等),如果可以连接到服务器,请检查您的PHP代

我正在使用PHP MAiler,但邮件没有被发送,事实上,我服务器上的网站一直在加载,没有显示任何错误。我甚至更改了我的gmail设置,允许使用不太安全的应用程序,但页面仍然没有加载,也没有显示任何错误。 代码:



我的Php mailer文件夹与此文件夹位于同一文件夹中,因此我想加载文件不是问题

您能否验证电子邮件是否未发送或未收到?这是有区别的。可能会对您有所帮助。首先,尝试使用您的凭据连接并配置另一个smtp客户端(theBat、outlook等),如果可以连接到服务器,请检查您的PHP代码。我尝试更改为ssl不起作用
<?php 
  error_reporting(E_ALL);

  require_once 'PHPMailer/PHPMailerAutoload.php';

  $mail = new PHPMailer;

$mail->SMTPDebug = 2;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'mohd.gadiwala@techmatters.com';                 // SMTP username
$mail->Password = 'password';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;                                    // TCP port to connect to

$mail->setFrom('mohd.gadiwala@techmatters.com', 'Mailer');
$mail->addAddress('mohd.gadiwala@techmatters.com', 'Joe User');     // Add a recipient
$mail->addAddress('ellen@example.com');               // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');

    // Optional name
// $mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}


 ?>