samedi 19 novembre 2016

PHPMailer - Fatal Error: class not found

I am building a website using PHP, and hosting it on 1&1 hosting. I installed composer on the server, and have used it to install PHPAuth and PHPMailer. I am running PHP 7.

PHPAuth uses PHPMailer to send emails, but whenever it tries to send an email I get the error Fatal error: Uncaught Error: Class 'PHPMailer\PHPMailer\PHPMailer' not found. I know it is being loaded in the composer autoloader as I can use PHPMailer in other files.

At the top of the PHPAuth file, the line use PHPMailer\PHPMailer\PHPMailer; is there, and it can't find the class. However, when I change it to just use PHPMailer;, I don't get an error but the page does not load - after a while it just says "The page you are looking for is temporarily unavailable. Please try again later. "

Here is PHPAuth and PHPMailer on GitHub.

I can't work out why it is saying it cannot find the class when called in PHPAuth, but works fine when it is called from another file (which is in the same directory as index.php, which is calling PHPAuth).

Thanks, Ben




Aucun commentaire:

Enregistrer un commentaire