2
votes

I am using Microsoft outlook SMTP details for sending emails from my website to other users.

I configured Queue/Jobs functionality to send emails.

SMTP settings

MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=abcyxz45
MAIL_FROM_NAME=ABC Mailer
[email protected]
MAIL_ENCRYPTION=tls

dispatching Job Code

$job    =   new SendReportEmail($job_data);
$this->dispatch($job);

mail sending code

class SendReportEmail extends Job implements SelfHandling, ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    var $data   =   null;

    public function __construct($data)
    {
        $this->data =   $data;
    }

    public function handle()
    {

        $response           =   $this->data['response'];
        $EntrepreneurPdf    =   $response->pdf;

        Mail::send('emailTemplates.imResults', ['response' => $response], function ($message) use ($response, $EntrepreneurPdf)  {

            $message->subject($response->subject);
            $message->to($response->provider_email);

            $this->checkForEntrepreneurReportAttachment($response, $message, $EntrepreneurPdf);

        });
    }
}

When I run this command to execute Queued jobs

php artisan queue:listen --timeout=300

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.

Processed: Illuminate\Queue\CallQueuedHandler@call


  [Swift_TransportException]                            
  Connection to tcp://smtp.office365.com:587 Timed Out

What and Where can be the issue?

1
Can you send emails using those credentials without queueing the job?Joe
Yes, I can send email using those credentials. Normal email as will as queuing job. But often I faces connection time out issue while working with queued Jobs.Qazi

1 Answers

0
votes

On your sever try ping the smtp

telnet smtp.office365.com 587