我在PHP
项目中部署了PHPMailer,而没有使用composer。
我可以使它工作,但奇怪的是,我的登录名却以突然丢失的 身份验证为代价。
警告:require_once(../ resources / PHPMailer / src / Exception.php):无法打开流:/Applications/XAMPP/xamppfiles/htdocs/ecom_march/ecom/resources/functions_contactus.php中没有此类文件或目录在第7行
致命错误:require_once():无法在/ Applications / XAMPP中打开所需的'../resources/PHPMailer/src/Exception.php'(include_path ='。:: / Applications / XAMPP / xamppfiles / lib / php') /xamppfiles/htdocs/ecom_march/ecom/resources/functions_contactus.php在第7行
我想知道什么可能导致冲突,或者我是否错误地实例化了该库。
functions_contactus.php
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once '../resources/PHPMailer/src/Exception.php';
require_once '../resources/PHPMailer/src/PHPMailer.php';
require_once '../resources/PHPMailer/src/SMTP.php';
function send_email_from_contact_form() {
if (isset($_POST['submit'])) {
$name = $_POST['fullname'];
$name = strip_tags(trim($_POST['fullname']));
$name = escape_string($_POST['fullname']);
$email = $_POST['email'];
$email = strip_tags(trim($_POST['email']));
$email = escape_string($_POST['email']);
$message = $_POST['message'];
$message = strip_tags(trim($_POST['message']));
$message = escape_string($_POST['message']);
$mail = new PHPMailer(true); // create a new instance of the PHPMailer class created
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SMTPSecure = "tls";
$mail->SMTPAuth = true;
$mail->Username = "chrisdorman1978@gmail.com"; // google username
$mail->Password = "blablabla"; //
$mail->setFrom($email); // send us the users email address
$mail->addAddress('chrisdorman1978@gmail.com'); // all emails will be sent to me at this address
$mail->isHTML(true);
$mail->Body = '<h1 align=text-center>Name : '.$_POST['fullname']. '<br>Email: '.$_POST['email'].'<br>Message: '.$_POST['message'].'</h1>';
if ($mail->send())
echo(" Your email has been sent");
else
echo("Sorry, your email has NOT been sent");
}
}/////////////////////////////end of send_email_from_contact_form*