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 Building Websites with PHP Contact Form & Sending Email Sending Our Email

Failure to Send Email

I did not expect to be able to successfully send an email over localhost, but I also did not expect to receive an error message. The problem that I am having is ascertaining whether or not there is an error in my code AND....what the following error information indicates:

The application could not run because of the following error: Details Type: ErrorException Code: 8 Message: Use of undefined constant Swift_SendmailTransport - assumed 'Swift_SendmailTransport' File: C:\xampp\htdocs\emerson_3\index.php Line: 43 Trace

0 C:\xampp\htdocs\emerson_3\index.php(43): Slim\Slim::handleErrors(8, 'Use of undefine...', 'C:\xampp\htdocs...', 43, Array)

1 [internal function]: {closure}()

2 C:\xampp\htdocs\emerson_3\vendor\slim\slim\Slim\Route.php(468): call_user_func_array(Object(Closure), Array)

3 C:\xampp\htdocs\emerson_3\vendor\slim\slim\Slim\Slim.php(1357): Slim\Route->dispatch()

4 C:\xampp\htdocs\emerson_3\vendor\slim\slim\Slim\Middleware\Flash.php(85): Slim\Slim->call()

5 C:\xampp\htdocs\emerson_3\vendor\slim\slim\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash->call()

6 C:\xampp\htdocs\emerson_3\vendor\slim\slim\Slim\Middleware\PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()

7 C:\xampp\htdocs\emerson_3\vendor\slim\slim\Slim\Slim.php(1302): Slim\Middleware\PrettyExceptions->call()

8 C:\xampp\htdocs\emerson_3\index.php(65): Slim\Slim->run()

9 {main}

1 Answer

Andrew Shook
Andrew Shook
31,709 Points

The undefined constant error usually mean you forgot to put a dollar sign in front of a variable before you used it. For example:

<?php
$message = "hello, world";

echo message;

However, in this case Swift_SendmailTransport is the name of a class so I don't think that a missing dollar sign is the problem. Can you post the code from your index.php so I could look over it. It says the error is on line 43, but sometimes you need to go back a line to figure out the actual problem.