This question already has an answer here:
I have deployed PHPMailer in my PHP
project without using composer.
I can get it to work but strangely at the expense of my login which all of a sudden does not authenticate with this error.
Warning: require_once(../resources/PHPMailer/src/Exception.php): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/ecom_march/ecom/resources/functions_contactus.php on line 7
Fatal error: require_once(): Failed opening required '../resources/PHPMailer/src/Exception.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/ecom_march/ecom/resources/functions_contactus.php on line 7
I am wondering what might cause the conflict or if I am instantiating this library incorrectly.
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*
</div>