Reputation: 1117
After doing a manual installation of PHPMailer, I can't get it to run, although everything seems to be right.
In my efforts to debug it, my impression is that it's failing on the 'require'. The path is correct with 'resources' being a directory at the root level of the site.
Is there a problem in nesting PHPMailer like this? I've tried moving it to the root level and still get no result.
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'resources/includes/PHPMailer/src/Exception.php';
require 'resources/includes/PHPMailer/src/PHPMailer.php';
require 'resources/includes/PHPMailer/src/SMTP.php';
FWIW, my debugging has been to insert an echo then terminate the script. It responds before the 'require' but not after.
Upvotes: 0
Views: 38
Reputation: 37810
Those require
paths are relative, and while they might be correct relative to your site's root, it's entirely possible that your site's root is not the current working directory from PHP's perspective (that might be somewhere odd, like /usr/bin
). You can solve that by making the current file's location the implicit root, like this:
require __DIR__ . '/resources/includes/PHPMailer/src/Exception.php';
require __DIR__ . '/resources/includes/PHPMailer/src/PHPMailer.php';
require __DIR__ . '/resources/includes/PHPMailer/src/SMTP.php';
The __DIR__
constant contains the folder containing the file that the current script is in. This should solve your immediate problem.
In the longer term, please learn how to use composer; you can thank me for it later :)
Upvotes: 1