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 A Third-Party Library

5 Answers

Hey Josh, are you looking for the class itself? Here it is: https://github.com/PHPMailer/PHPMailer/blob/master/src/PHPMailer.php.

You could create a new file called class.phpmailer.php and just copy/paste the contents from that Github page. It looks like the maintainers have re-organized the Github repo a bit.

Yep... in her video, the current PHPmailer version is 5.2.14, which was released Nov. 2, 2015.

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Yep, the new version doesn't have that class individually for download. The instructions show how to do it that way, but I chose to adjust and use the new version following the recommended install via composer locally. It was straight forward and also added in using the gmail SMTP server to actually send mail (was in the examples). Just let me know if you want any details.

Sweet!

I'm having the same problem. Not following the solution.

Looks like there was a massive update on the PHPMailer. I hope this will help you. I had to read the docs on GitHub to figure it out. Some tinkering around, finally got it.

Rather than one file, you actually will need two files added into your inc/phpmailer folder (1) Exception.php (2) PHPMailer.php

Next, in your suggest.php file, at the top write after the first line <?php you'll need to include:

use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;

Then, in where our instructor, Alena, says to include the require, there's two lines of code needed:

require 'inc/phpmailer/Exception.php'; require 'inc/phpmailer/PHPMailer.php';

The last difference is the following:

$mail = new PHPMailer(true);

The if-statement for ValidateAddress is still the same as instructed.