I have some problems for a long time now.
My app is sending mails to the customers.
In last months I've migrated this app to the Laravel (5.4 currently).
Many times I am receiving error:
Swift_TransportException in AbstractSmtpTransport.php line 404:
Connection to my-smtp.company.com:25 Timed Out
Problem is that I cannot get rid of this error message.
It happen in about 10% of cases - or queued task and mails sent in realtime.
Strange is that those mails are send out in fact but error show up anyway.
I am using Windows server and for queued mails running listener this way:
D:\php-7.1.1-x64\php.exe D:\wwwroot\myapp\artisan queue:listen --timeout=60 --tries=1
I've made some tests and looks like when errors is throws it is always after 33-36 second after firing queue job or executing code in browser.
Changed max_execution_time
time to the 60 seconds but that didn't helped.
Anyone can help me?
I have the same problem, and my app running on Laravel 6.0
My solution:
1) create a custom mail service provider.
2) use SwiftTransport method "setTimeout".
<?php
namespace App\Providers;
use Illuminate\Mail\MailServiceProvider as MailProvider;
use Illuminate\Mail\TransportManager;
class MailServiceProvider extends MailProvider
{
/**
* Register the Swift Transport instance.
*
* @return void
*/
protected function registerSwiftTransport()
{
$this->app->singleton('swift.transport', function ($app) {
$transport = new TransportManager($app);
$transport->setTimeout(config('mail.connection_timeout'));
return $transport;
});
}
}
3) replace provider config in \config\app.php
'provider' => [
...
// Illuminate\Mail\MailServiceProvider::class,
App\Providers\MailServiceProvider::class,
...
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With