mercredi 19 décembre 2018

Laravel 5.4 Try/Catch in a mailable build() method when sending 2400 emails or another way to catch/log emails that aren't sent?

I'm using laravel 5.4 and need to loop through 2400 customer accounts to create individual tokenized emails to send to each. I'm wondering what the best way might be to track emails that fail for whatever reason. The mailable is implementing ShouldQueue and I was thinking of something along these lines:

try {
    return $this->bcc($this->email)
                ->from('test@example.com')
                ->subject('Some subject')
                ->markdown('emails.Markdown');
} catch (\Exception $e) {
    Log::info('Email did not send ' . $this->email);
}

Will that work to actually continue on and Log the failed email or is there a better way to go about this? Does laravel throw an exception if an email doesn't send?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire