diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index ad58e767eebc..88f6a860b16c 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -47,9 +47,9 @@ class NinjaMailerJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, MakesHash; - public $tries = 5; //number of retries + public $tries = 3; //number of retries - public $backoff = 5; //seconds to wait until retry + public $backoff = 10; //seconds to wait until retry public $deleteWhenMissingModels = true; @@ -106,7 +106,7 @@ class NinjaMailerJob implements ShouldQueue //send email try { - nlog("trying to send"); + nlog("trying to send to {$this->nmo->to_user->email} ". now()->toDateTimeString()); Mail::to($this->nmo->to_user->email) ->send($this->nmo->mailable); diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 528ba6bcec82..97c5b37907af 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -48,22 +48,22 @@ class ReminderJob implements ShouldQueue //multiDB environment, need to foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); - - $this->processReminders($db); + $this->processReminders(); } } } - private function processReminders($db = null) + private function processReminders() { Invoice::where('next_send_date', Carbon::today()->format('Y-m-d'))->with('invitations')->cursor()->each(function ($invoice) { + if ($invoice->isPayable()) { $reminder_template = $invoice->calculateTemplate('invoice'); $invoice->service()->touchReminder($reminder_template)->save(); $invoice->invitations->each(function ($invitation) use ($invoice, $reminder_template) { EmailEntity::dispatch($invitation, $invitation->company, $reminder_template); - nlog("Firing email for invoice {$invoice->number}"); + nlog("Firing reminder email for invoice {$invoice->number}"); }); if ($invoice->invitations->count() > 0) { @@ -73,6 +73,7 @@ class ReminderJob implements ShouldQueue $invoice->next_send_date = null; $invoice->save(); } + }); } }