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! While you're at it, check out some resources Treehouse students have shared here.

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 Basic PHP Website (2018) Adding a Basic Form Using Object and Validating Email

Paul M
Paul M
16,370 Points

PHP Error

I received this message

Warning: require(inc/phpmailer/class.phpmailer.php): failed to open stream: No such file or directory in /home/treehouse/workspace/suggest.php on line 17

Fatal error: require(): Failed opening required 'inc/phpmailer/class.phpmailer.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/treehouse/workspace/suggest.php on line 17

Does anyone know how to fix it?


  $name = trim(filter_input(INPUT_POST,"name",FILTER_SANITIZE_STRING));
  $email = trim(filter_input(INPUT_POST,"email",FILTER_SANITIZE_EMAIL));
  $details = trim(filter_input(INPUT_POST,"details",FILTER_SANITIZE_SPECIAL_CHARS));

  if (trim($name) == "" || $email == "" || $details == "") {
    echo "Please fill out the required fields: Name, Email, Details";
  if ($_POST["address"] != "") {
    echo "Bad form input";


  $mail = new PHPMailer;

  if (!$mail->ValidateAdress($email)) {
    echo "Invalid Email Address";

5 Answers

Make sure the file path is correct, whenever you get that issue, it means the file isn't found.

"failed to open stream: No such file or directory in ... on line 17"

Kevin Korte
Kevin Korte
28,148 Points

Yep, as Luke said, check your path. It's not able to find your file you are requiring at "inc/phpmailer/class.phpmailer.php"

This issue because namespace. In class.phpmailer.php file remove namespace line

Jaime Rios
Jaime Rios
Courses Plus Student 21,100 Points

For me it worked when i wrote validateAddress instead of .ValidateAddress

Akash yadav
Akash yadav
10,046 Points

Here is your code:

if (!$mail->ValidateAdress($email)) { echo "Invalid Email Address"; exit; }

No, one noticed down one simple error, i.e check the spelling of Address in ValidateAddress. you have surely missed an alphabet "d".