2

I am trying to send and email for verification of a registration for my website i keep getting this error and I don't know how to fix it. These errors:

Warning: require(./vendor/autoload.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\BUDGETING_WEBSITE\includes\signup.inc.php on line 7

Fatal error: Uncaught Error: Failed opening required './vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\BUDGETING_WEBSITE\includes\signup.inc.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\BUDGETING_WEBSITE\includes\signup.inc.php on line 7

I installed phpMailer using Composer through the terminal. This is my code:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

//Load Composer's autoloader
require 'vendor/autoload.php';


function sendemail_verify($full_name,$email,$verify_token)
{
    $mail = new PHPMailer(true);
    $mail->isSMTP();                                                        //Send using SMTP
    $mail->Host       = 'smtp.gmail.com';                                   //Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                               //Enable SMTP authentication
medilies
  • 1,811
  • 1
  • 8
  • 32
LP1
  • 46
  • 6
  • 1
    did you set the username and password ? – medilies Mar 12 '22 at 13:39
  • 1
    Can you show us your error? – gguney Mar 12 '22 at 13:40
  • 1
    There is an issue with your folder structure, or autoloader or the way you installed the package – medilies Mar 12 '22 at 13:42
  • 1
    it is required that your question shows at least what are the steps you followed to bring **PHPMailer** package to your project. (for example: composer command, where you put the autoloader of composer ...) – medilies Mar 12 '22 at 13:57
  • 1
    **I also do not understand why this question got 2 upvotes in 10 minutes while it is still not clear** – medilies Mar 12 '22 at 13:58
  • @kmoser Yes it does thank you but now I have a different error lol. Now even after i run the command composer require phpmailer/phpmailer it's like php mailer is not installed. – LP1 Mar 12 '22 at 16:17
  • 1
    @LP1 _"it's like php mailer is not installed"_ What does that mean? Please describe the specific symptoms or behavior you are experiencing. – kmoser Mar 12 '22 at 16:19
  • @kmoser At the top of my page I have the mandatory code which calls for the phpMailer (use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception;) this one to be precise. But the ide is giving me a warning which says that those classes are unkown to it as if i didn't install PHPMailer. So when i test my website i get an error where it says Fatal error: Uncaught Error: Class "PHPMailer" not found in C:\xampp\htdocs\BUDGETING_WEBSITE\ – LP1 Mar 12 '22 at 16:22
  • 1
    Those `use` statements don't load anything, they are just local aliases for namespaced classes. the loading is done by the autoloader, which you seem to be missing, suggesting you have not run `composer install` in your project, which will create `autoload.php` and populate the `vendor` folder. – Synchro Mar 12 '22 at 16:46
  • @Synchro i did run that and updated my code from the one you see on this page but even after running ```composer install``` and deleting the use PHPMailer statemnts i get the error – LP1 Mar 12 '22 at 16:51
  • 1
    So show us the `require` section of your `composer.json` file. You still need the `use` statements, so put them back, [as the PHPMailer examples demonstrate](https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps). – Synchro Mar 12 '22 at 17:19
  • @Synchro this problem has been solved now I have a different error message for which I posted a different question. – LP1 Mar 12 '22 at 17:22
  • @Synchro and my require section does have ``` ``` "require": { "phpmailer/phpmailer": "^6.6" } ``` – LP1 Mar 12 '22 at 17:23

0 Answers0