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

Anthony Cunarro
Anthony Cunarro
3,489 Points

Slim Application Error

Things are getting a bit rough now with PHP but I am sticking with it. With Forms and Email I got the following error: Slim Application Error

The application could not run because of the following error:

Details

Type: Swift_TransportException

Message: Expected response code 220 but got code "", with message ""

File: /home/treehouse/workspace/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php

Line: 383

Trace

0 /home/treehouse/workspace/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(289): Swift_Transport_AbstractSmtpTransport->_assertResponseCode('', Array)

1 /home/treehouse/workspace/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(117): Swift_Transport_AbstractSmtpTransport->_readGreeting()

2 /home/treehouse/workspace/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php(51): Swift_Transport_AbstractSmtpTransport->start()

3 /home/treehouse/workspace/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(79): Swift_Transport_SendmailTransport->start()

4 /home/treehouse/workspace/index.php(66): Swift_Mailer->send(Object(Swift_Message))

5 [internal function]: {closure}()

6 /home/treehouse/workspace/vendor/slim/slim/Slim/Route.php(468): call_user_func_array(Object(Closure), Array)

7 /home/treehouse/workspace/vendor/slim/slim/Slim/Slim.php(1357): Slim\Route->dispatch()

8 /home/treehouse/workspace/vendor/slim/slim/Slim/Middleware/Flash.php(85): Slim\Slim->call()

9 /home/treehouse/workspace/vendor/slim/slim/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call()

10 /home/treehouse/workspace/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()

11 /home/treehouse/workspace/vendor/slim/slim/Slim/Slim.php(1302): Slim\Middleware\PrettyExceptions->call()

12 /home/treehouse/workspace/index.php(80): Slim\Slim->run()

2 Answers

If you are using GMail then take notice that GMail's SMTP requires encryption. Use Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl").

I had exactly the same application error . Which occurred in this line of code:

$transport = Swift_SendmailTransport::newInstance('usr/sbin/sendmail -bs');

I did not specify the correct path. It is necessary to add a forward slash (/) to the beginning of this path before the usr directory as follows:

$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');

The above line of code resolved the problem.

Jan Park
Jan Park
4,296 Points

Thank you, Peter, I did not make the same mistake as you did, but your answer led me to review my code thoroughly.<br> Fortunately I found the error, which was, instead of: [some_code]('/usr/sbin/sendmail -bs')[/some_code]. I've written [some_code]('/user/...')[/some_code] after fixing my mistake with: <br>

$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');

the message was send succesfully, thank you!