phplaravelemailmailhog

Laravel 5.2: Expected response code 220 but got code "500", with message "500 Unrecognised command


I am trying to test the email functionality on my app and it is rendering the following error:

Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 220 but got code "500", with message "500 Unrecognised command

I am using vagrant homestead for Laravel 5.2. For testing mail I am using MailHog. Here is my .env:

MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

Here are my logs:

[2020-12-23 08:23:03] local.ERROR: Swift_TransportException: Expected response code 220 but got code "500", with message "500 Unrecognised command
" in /home/vagrant/code/admin/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:383
Stack trace:
#0 /home/vagrant/code/admin/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(281): Swift_Transport_AbstractSmtpTransport->_assertResponseCode('500 Unrecognise...', Array)
#1 /home/vagrant/code/admin/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(270): Swift_Transport_AbstractSmtpTransport->executeCommand('STARTTLS\r\n', Array, Array)
#2 /home/vagrant/code/admin/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(311): Swift_Transport_EsmtpTransport->executeCommand('STARTTLS\r\n', Array)
#3 /home/vagrant/code/admin/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(118): Swift_Transport_EsmtpTransport->_doHeloCommand()
#4 /home/vagrant/code/admin/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start()
#5 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(385): Swift_Mailer->send(Object(Swift_Message), Array)
#6 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(171): Illuminate\Mail\Mailer->sendSwiftMessage(Object(Swift_Message))
#7 /home/vagrant/code/admin/bootstrap/cache/compiled.php(6329): Illuminate\Mail\Mailer->send('emails.release-...', Array, Object(Closure))
#8 /home/vagrant/code/admin/app/Http/Controllers/EmailController.php(41): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
#9 [internal function]: App\Http\Controllers\EmailController->sendEmail(Object(App\Http\Requests\SendEmailRequest))
#10 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9424): call_user_func_array(Array, Array)
#11 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9486): Illuminate\Routing\Controller->callAction('sendEmail', Array)
#12 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9466): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\EmailController), Object(Illuminate\Routing\Route), 'sendEmail')
#13 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#14 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#15 /home/vagrant/code/admin/app/Http/Middleware/Authenticate.php(47): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#16 [internal function]: App\Http\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))
#17 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9963): call_user_func_array(Array, Array)
#18 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#19 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#20 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#21 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9948): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#22 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9467): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#23 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9454): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\EmailController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'sendEmail')
#24 /home/vagrant/code/admin/bootstrap/cache/compiled.php(8524): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\\Http\\Contro...', 'sendEmail')
#25 /home/vagrant/code/admin/bootstrap/cache/compiled.php(8511): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))
#26 /home/vagrant/code/admin/bootstrap/cache/compiled.php(8225): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#27 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#29 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#30 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9948): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#31 /home/vagrant/code/admin/bootstrap/cache/compiled.php(8226): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#32 /home/vagrant/code/admin/bootstrap/cache/compiled.php(8217): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#33 /home/vagrant/code/admin/bootstrap/cache/compiled.php(8207): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#34 /home/vagrant/code/admin/bootstrap/cache/compiled.php(2419): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#35 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#36 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#37 /home/vagrant/code/admin/app/Http/Middleware/SslRedirect.php(22): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#38 [internal function]: App\Http\Middleware\SslRedirect->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9963): call_user_func_array(Array, Array)
#40 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#42 /home/vagrant/code/admin/bootstrap/cache/compiled.php(13474): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#43 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9963): call_user_func_array(Array, Array)
#45 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#46 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#47 /home/vagrant/code/admin/bootstrap/cache/compiled.php(11964): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#48 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#49 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9963): call_user_func_array(Array, Array)
#50 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#51 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#52 /home/vagrant/code/admin/bootstrap/cache/compiled.php(13213): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#53 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#54 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9963): call_user_func_array(Array, Array)
#55 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#56 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#57 /home/vagrant/code/admin/bootstrap/cache/compiled.php(13150): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#58 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#59 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9963): call_user_func_array(Array, Array)
#60 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#61 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#62 /home/vagrant/code/admin/bootstrap/cache/compiled.php(3286): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#63 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#64 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9963): call_user_func_array(Array, Array)
#65 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#66 /home/vagrant/code/admin/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#67 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#68 /home/vagrant/code/admin/bootstrap/cache/compiled.php(9948): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#69 /home/vagrant/code/admin/bootstrap/cache/compiled.php(2366): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#70 /home/vagrant/code/admin/bootstrap/cache/compiled.php(2350): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#71 /home/vagrant/code/admin/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#72 {main}  

What is going wrong here? What is the solution?


Solution

  • MailHog does not support TLS encryption. Adding MAIL_ENCRYPTION=

    MAIL_ENCRYPTION=