By tuhinpaul
0
I don’t know how to go about debugging this. Any help would be great!
I am using Laravel 4.2 (I know it’s high time I upgrade). I am sending mail using Gmail SMTP. I am able to send mail on local environment without issue, but on the production server it is throwing the following error:
[2020-11-20 15:55:52] production.ERROR: ErrorException: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14161044:SSL routines:state_machine:internal error in /var/www/domain.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:94
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'stream_socket_e...', '/var/www/domain...', 94, Array)
#1 /var/www/domain.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php(94): stream_socket_enable_crypto(Resource id #10, true, 9)
#2 /var/www/domain.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(313): Swift_Transport_StreamBuffer->startTLS()
#3 /var/www/domain.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(118): Swift_Transport_EsmtpTransport->_doHeloCommand()
#4 /var/www/domain.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start()
#5 /var/www/domain.com/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(307): Swift_Mailer->send(Object(Swift_Message), Array)
#6 /var/www/domain.com/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(134): Illuminate\Mail\Mailer->sendSwiftMessage(Object(Swift_Message)) #7 /var/www/domain.com/bootstrap/compiled.php(3180): Illuminate\Mail\Mailer->send('emails.bulk-ord...', Array, Object(Closure))
#8 /var/www/domain.com/app/libraries/functions/sendMail.php(34): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
#9 /var/www/domain.com/app/controllers/BulkOrderController.php(70): App\Libraries\Functions\sendMail('emails.bulk-ord...', Array, Array, 1)
#10 [internal function]: BulkOrderController->checkout()
#11 /var/www/domain.com/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(231): call_user_func_array(Array, Array)
#12 /var/www/domain.com/bootstrap/compiled.php(5437): Illuminate\Routing\Controller->callAction('checkout', Array)
#13 /var/www/domain.com/bootstrap/compiled.php(5425): Illuminate\Routing\ControllerDispatcher->call(Object(BulkOrderController), Object(Illuminate\Routing\Route), 'checkout')
#14 /var/www/domain.com/bootstrap/compiled.php(4657): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'BulkOrderContro...', 'checkout')
#15 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#16 /var/www/domain.com/bootstrap/compiled.php(4984): call_user_func_array(Object(Closure), Array)
#17 /var/www/domain.com/bootstrap/compiled.php(4682): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#18 /var/www/domain.com/bootstrap/compiled.php(4670): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#19 /var/www/domain.com/bootstrap/compiled.php(706): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#20 /var/www/domain.com/bootstrap/compiled.php(687): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#21 /var/www/domain.com/bootstrap/compiled.php(7311): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#22 /var/www/domain.com/bootstrap/compiled.php(7908): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#23 /var/www/domain.com/bootstrap/compiled.php(7855): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#24 /var/www/domain.com/bootstrap/compiled.php(10990): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#25 /var/www/domain.com/bootstrap/compiled.php(648): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#26 /var/www/domain.com/public/index.php(49): Illuminate\Foundation\Application->run()
The code is hosted on a DigitalOcean droplet (Ubuntu 20.04).
Contents of app/config/mail.php:
<?php
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => 'contact@domain.com', 'name' => 'Company Name'),
'encryption' => 'tls',
'username' => 'GmailUserName',
'password' => 'GmailPassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there @tuhinpaul,
Indeed as you mentioned, it would be best to go ahead and upgrade but it definitely can be challenging.
I could not replicate this myself, but you could try the suggestion from this discussion here:
Edit the config/mail.php file and add the following:
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
Note: this is not ideal as it is essentially disabling TLS and could have some security implications.
Let me know how it goes! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
