Skip to content
Advertisement

unable to use PHPMAILER to send email

I have just downloaded PHPMAILER from github to send emails to users . My problem is that when I try to run the php file with PHPMAILER from localhost I get the error

JavaScript

where sendmail.php is the file with the phpmailer sample code to send an email . I believe that there’s a problem with the location of the phpmailer repo I downloaded so I will show you how my project folder is set up with the repo inside :

enter image description here

PHPMailer-5.2-... is the zip file and PHPMAILER_FOLDER is the unzipped one . I have just renamed it . The PROJECT FOLDER is the one with the long name on top and is located in xampp/htdocs My sendmail.php code (the sample code without my credentials):

JavaScript

I have also added "phpmailer/phpmailer": "~5.2" to my composer.json with the same result I would appreciate your help . Thank you in advance .

Advertisement

Answer

If your sendmail.php is in the “root folder” of your project, but PHPMailerAutoload.php is in “PHPMAILER_FOLDER” then you need to include it like this:

JavaScript

But do you even have such a file? From what I can see PHPMailer does not ship one, have you created one yourself?

You need to point to the file.

If you prefer using autoloader generated by composer then usually it creates a folder called vendor and then instead of autoloading using the autoloader from phpmailer include the one generated by composer and add the required use statements:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement