title: Laravel Queue, Connection to tcp://smtp.office365.com:587 Timed Out
body: <p>I am using <code>Microsoft outlook SMTP</code> details for sending emails from my website to other users.</p>
  
  <p>I configured Queue/Jobs functionality to send emails.</p>
  
  <p><strong>SMTP settings</strong></p>
  
  <pre><code>MAIL_DRIVER=smtp
  MAIL_HOST=smtp.office365.com
  MAIL_PORT=587
  MAIL_USERNAME=info@abcxyz.com
  MAIL_PASSWORD=abcyxz45
  MAIL_FROM_NAME=ABC Mailer
  MAIL_FROM_EMAIL=info@abcxyz.com
  MAIL_ENCRYPTION=tls
  </code></pre>
  
  <p><strong>dispatching Job Code</strong></p>
  
  <pre><code>$job    =   new SendReportEmail($job_data);
  $this-&gt;dispatch($job);
  </code></pre>
  
  <p><strong>mail sending code</strong></p>
  
  <pre><code>class SendReportEmail extends Job implements SelfHandling, ShouldQueue
  {
      use InteractsWithQueue, SerializesModels;
  
      var $data   =   null;
  
      public function __construct($data)
      {
          $this-&gt;data =   $data;
      }
  
      public function handle()
      {
  
          $response           =   $this-&gt;data['response'];
          $EntrepreneurPdf    =   $response-&gt;pdf;
  
          Mail::send('emailTemplates.imResults', ['response' =&gt; $response], function ($message) use ($response, $EntrepreneurPdf)  {
  
              $message-&gt;subject($response-&gt;subject);
              $message-&gt;to($response-&gt;provider_email);
  
              $this-&gt;checkForEntrepreneurReportAttachment($response, $message, $EntrepreneurPdf);
  
          });
      }
  }
  </code></pre>
  
  <p>When I run this command to execute Queued jobs</p>
  
  <p><code>php artisan queue:listen --timeout=300</code></p>
  
  <p>Process is starts, and sometimes I got below error, so due to error and queued again and again attempts, I got same email multiple times.</p>
  
  <blockquote>
  <pre><code>Processed: Illuminate\Queue\CallQueuedHandler@call
  
  
    [Swift_TransportException]                            
    Connection to tcp://smtp.office365.com:587 Timed Out
  </code></pre>
  </blockquote>
  
  <p>What and Where can be the issue? </p>