Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress How to Install WordPress on Your Computer How to Install WordPress on Your Computer How to Enable Email for WordPress on Your Computer

Daniel Schroeder
Daniel Schroeder
13,859 Points

Test Email throws PHP Errors: Class SMTP Not Found

I'm just setting up WordPress to run on Ubuntu 16.04 and had the following error message popup when I tried to send a test email (through my gmail account) from EASY WP SMTP:

( ! ) Fatal error: Uncaught Error: Class 'SMTP' not found in /usr/share/php/libphp-phpmailer/class.phpmailer.php on line 1446
( ! ) Error: Class 'SMTP' not found in /usr/share/php/libphp-phpmailer/class.phpmailer.php on line 1446
Call Stack

I checked /usr/share/php/libphp-phpmailer/ and there was definitely a class.smtp.php in there, so I have no idea why this error is occurred. I decided to just include the class.smtp.php in the class.phpmailer.php file by adding this line to /usr/share/php/libphp-phpmailer/class.phpmailer.php and it fixed the issue:

include 'class.smtp.php';

I'm a novice PHP user, and brand new to WordPress, so can anyone explain why this issue occurred in the first place? Why can class.phpmailer.php not find class.smtp.php if they are both in the same package and directory? Why is the include statement needed?