0

I have recently been trying to add PHPMailer script to my site, following the accepted answer from here:

Send attachments with PHP Mail()?

I have never used a require statment before so I assume I must be doing it wrong, currently testing on my local host version of the site. I have downloaded the entire zip of git (unzipped it) and moved it to the dir my scripts are in.

In my script I added the following line:

require_once(__DIR__.'/PHPMailer-master/class.phpmailer.php');

Which to my understanding was all I needed to do to use it. However I get this error:

Warning: require_once(C:\xampp\htdocs\Website\PHPMailer-master\class.phpmailer.php): failed to open stream: No such file or directory in C:\xampp\htdocs\Website\include\mailer.php on line 10

Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs\Website\PHPMailer-master\class.phpmailer.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\Website\include\mailer.php on line 10

Any ideas what is causing this error? Am running PHP 5.6.21 if this is relevant.

mujuonly
  • 11,370
  • 5
  • 45
  • 75
Lain
  • 2,166
  • 4
  • 23
  • 47

1 Answers1

0

Try to use the full path to the file, using realpath() - http://php.net/realpath, and use dirname(__FILE__) to get your current directory:

Farhad Hossen
  • 263
  • 1
  • 6