I have a problem with setting up PHPMailer. It was working before, but now all of a sudden it stopped and this is the error I’m getting:
PHP Fatal error: require(): Failed opening required '../src/PHPMailer.php' (include_path='.:/opt/cpanel/ea-php53/root/usr/share/pear:/opt/cpanel/ea-php53/root/usr/share/php') in /home/pandatra/site.com/contacts_form/contact_form.php on line 9
Here is the code in contact_form.php:
<?php
include 'config.php';
use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerException;
use PHPMailerPHPMailerSMTP;
require ''.$d['include_path'].'PHPMailer/src/Exception.php';
require ''.$d['include_path'].'PHPMailer/src/PHPMailer.php';
require ''.$d['include_path'].'PHPMailer/src/SMTP.php';
$mail = new PHPMailer(true);
if (isset($_POST['Send'])) {
How to fix this? Any ideas? I downloaded version 6.1.7 of PHPMailer.
2
Answers
Here’s the problem:
If you upgraded from 5.x to 6.x, you needed to read either the readme, the upgrade guide, or this question and answer that was specifically created to deal with this issue.
The error you mentioned is that, the path in your require is getting Wrong. To avoid this type of problem , you should always use absolute path
e.g.
__DIR__ is the absolute path of running file’s directory.