$this->templateVariables = $this->processVariablesForMailer();
foreach ($this->users as $user) {
- Mail::send([], [], function ($message) use ($user) {
- $h = $this->html;
- $h = str_replace('%name%', $user->name, $h);
- $h = str_replace('%url%', $this->batch->file->getMailableUrl($user), $h);
- $h = str_replace('%cover%', $this->batch->file->coverUrl, $h);
-
- $message->from(config('mail.from.address'), config('mail.from_name'));
- $message->subject($this->batch->subject);
- $message->setBody($h, 'text/html');
- $message->to($user->email);
- $message->replyTo(env('MAIL_REPLYTO'));
- });
+ for ($j = 0; $j < 4; $j++) {
+ try {
+ Mail::send([], [], function ($message) use ($user) {
+ $h = $this->html;
+ $h = str_replace('%name%', $user->name, $h);
+ $h = str_replace('%url%', $this->batch->file->getMailableUrl($user), $h);
+ $h = str_replace('%cover%', $this->batch->file->coverUrl, $h);
+
+ $message->from(config('mail.from.address'), config('mail.from_name'));
+ $message->subject($this->batch->subject);
+ $message->setBody($h, 'text/html');
+ $message->to($user->email);
+ $message->replyTo(env('MAIL_REPLYTO'));
+ });
+ break;
+ } catch (\Exception $e) {
+ sleep(30);
+ }
+ }
$this->processUpdate([
'status' => 'processing',