Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am currently working on a project that has a forgot password system in it. I decided to use PHPMailer to send reset password email to the user and I installed it via Composer and it is now in the vendor folder. However, after implementing the sample codes, PHP throws an error:

Notice: Undefined variable: mail in /opt/lampp/htdocs/capstone-admin/process/loginFunctions.php on line 98

Fatal error: Uncaught Error: Call to a member function isSMTP() on null in /opt/lampp/htdocs/capstone-admin/process/loginFunctions.php:98 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/capstone-admin/process/loginFunctions.php on line 98


Here is a portion of my code in the loginFunctions.php:

<?php 
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\SMTP;
    use PHPMailer\PHPMailer\Exception;

    require __DIR__. '/../vendor/autoload.php';
    $mail = new PHPMailer();
    $mail->isSMTP();
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'ssl';
    // More codes ......
?>


And my directory structure is:

- assets
- helpers
- process
  - loginFunctions.php
- vendor
  - composer
  - phpmailer / phpmailer
  - autoload.php
- views
- .gitignore
- composer.json
- composer.lock
- index.php
- README.md


What I have tried:

I tried searching for common questions and watching youtube videos but still no luck unfortunately. Any help is appeciated!
Posted
Comments
Richard MacCutchan 28-Dec-19 4:17am    
Looking at your directory structure it may be that the paths in your use and require statements are not correct.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900