2

enter image description here

I'm trying to include PHP mailer but getting this error:

enter image description here

the location of PHP Mailer is:

enter image description here

and the php.ini file has that as the correct includes path:

enter image description here

and that php.ini file is the one that PHPInfo() gave me.

What am I missing here? Did I break PHP? Was everyone right about PHP all along? Am I a dupe?

2
  • Have you tried uncommenting the UNIX include path? Commented Aug 2, 2015 at 0:46
  • Why are you not using composer? Commented Aug 2, 2015 at 7:26

3 Answers 3

5

Your include_path is commented out

;include_path = ".:/usr/share/php"
^ remove semicolon
Sign up to request clarification or add additional context in comments.

1 Comment

I ended up using set_include_path ( '/usr/share/php/'); which worked but I did what you suggested and commented out the above and it still worked. So maybe that was it :)
3

Your directory is named libphp-phpmailer and in the require_once you name it libphp-PHPMailer (with upper case letters).

Comments

0

You're using an old version of PHPMailer and you're loading it in the wrong way. Please get the latest version and read the docs on loading, or add PHPMailer to your composer.json.

For a manual load you should do:

require '/path/to/PHPMailerAutoload.php';
$mail = new PHPMailer;

As you're using composer (though you've commented it out), you don't even need to do that much since the composer autoloader will work.

You've also based your code on an old example, so I suggest you update that too using one of the examples provided.

1 Comment

Yup, I was following the Harvard CS50 MOOC example which is likely dated. I'm also using their ubuntu distro which must have had some of these quirks. I've since resolved everything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.