Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Wrapping Up The Project Using A Third-Party Library

Paul Barron
Paul Barron
6,595 Points

php problems

$mail = new PHPMailer(); can't find this in the thirdparty phpmailer. I guess because this is an older video.

This is what I have, but I don't if there is something wrong:

$mail = new PHPMailer();

if ($mail->ValidateAddress($email)){
    echo "You must specify a valid email adress.";

I keep getting this error:

Warning: require(PHPMailerAutoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\nsm_cleaning\class.phpmailer.php on line 578

Fatal error: require(): Failed opening required 'PHPMailerAutoload.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\nsm_cleaning\class.phpmailer.php on line 578

I don't have a line 578... HELP!!!!

2 Answers

Robert Bojor
Robert Bojor
Courses Plus Student 29,439 Points

From the error message it looks like you are missing the PHPMailerAutoload.php from your inclusion path.

When working with PHPMailer you should have at least the following files in the folder you're going to use for inclusion:

  • class.phpmailer.php
  • class.pop3.php
  • class.smtp.php
  • PHPMailerAutoload.php

and always include the PHPMailerAutoload.php file in your code - it will take care of the rest.

You can grab the latest version from https://github.com/PHPMailer/PHPMailer

Paul Barron
Paul Barron
6,595 Points

For clarification, do I put the said files in the same folder as the phpmailer file and thats it?