Php 无法发送邮件。邮件程序错误:

Php 无法发送邮件。邮件程序错误:,php,html,phpmailer,Php,Html,Phpmailer,伙计们,我现在正在使用php mailer库。我有一些与mail()相关的错误 功能。 这是我的源代码 <?php require 'class.phpmailer.php'; $mail = new PHPMailer; $mail->IsSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.google.com';

伙计们,我现在正在使用php mailer库。我有一些与mail()相关的错误 功能。 这是我的源代码

<?php
require 'class.phpmailer.php';

$mail = new PHPMailer;

$mail->IsSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.google.com';                 // Specify main and backup server
$mail->Port = 587;                                    // Set the SMTP port
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'venki14101996@gmail.com';                // SMTP username
$mail->Password = '8903273610';                  // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted

$mail->From = 'venki14101996@gmail.com';
$mail->FromName = 'VENKAT';
$mail->AddAddress('venkat14101996@gmail.com', 'Josh Adams');  // Add a recipient
$mail->AddAddress('rishi27052001@gmail.com');               // Name is optional

$mail->IsHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <strong>in bold!</strong>';
$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;
   exit;
}

echo 'Message has been sent';

尝试添加以下代码

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

嗨,伙计,这显示了一个错误消息警告:require(PHPMailer/src/Exception.php):无法打开流:第6行的C:\xampp\htdocs\PHPMailer\mmaaill.php中没有这样的文件或目录致命错误:require():无法打开必需的“PHPMailer/src/Exception.php”(include_path='\xampp\php\PEAR'))在第6行的C:\xampp\htdocs\phpmailer\mmaail.php中,我想我没有一些文件,请向我推荐一个下载phpmailer文件夹的好网站。这是我的phpmailer文件夹,仅适用于当前版本;OP使用的是一个过时的版本。请阅读自述文件-它告诉您如何在有或没有composer的情况下加载PHP编译器。你也需要这样做。
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';