mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for mail
This commit is contained in:
parent
ef9043db44
commit
f1c1243146
@ -116,13 +116,13 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
|
||||
$this->invitation->contact->client
|
||||
)
|
||||
);
|
||||
} catch (Swift_TransportException $e) {
|
||||
} catch (\Exception $e) {
|
||||
$this->failed($e);
|
||||
$this->entityEmailFailed($e->getMessage());
|
||||
$this->logMailError($e->getMessage(), $this->entity->client);
|
||||
}
|
||||
|
||||
if (count(Mail::failures()) > 0) {
|
||||
$this->logMailError(Mail::failures(), $this->entity->client);
|
||||
} else {
|
||||
if (count(Mail::failures()) == 0) {
|
||||
$this->entityEmailSucceeded();
|
||||
}
|
||||
|
||||
@ -130,19 +130,6 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
|
||||
$this->entity->service()->markSent()->save();
|
||||
}
|
||||
|
||||
public function failed($exception = null)
|
||||
{
|
||||
info('the job failed');
|
||||
|
||||
$job_failure = new EmailInvoiceFailure();
|
||||
$job_failure->string_metric5 = $this->entity_string;
|
||||
$job_failure->string_metric6 = $exception->getMessage();
|
||||
|
||||
LightLogs::create($job_failure)
|
||||
->batch();
|
||||
|
||||
}
|
||||
|
||||
private function resolveEntityString() :string
|
||||
{
|
||||
if($this->invitation instanceof InvoiceInvitation)
|
||||
|
@ -94,9 +94,15 @@ class ZipInvoices extends BaseMailerJob implements ShouldQueue
|
||||
|
||||
$this->setMailDriver();
|
||||
|
||||
Mail::to($this->email)
|
||||
->send(new DownloadInvoices(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company));
|
||||
try {
|
||||
Mail::to($this->email)
|
||||
->send(new DownloadInvoices(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company));
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->failed($e);
|
||||
|
||||
}
|
||||
|
||||
UnlinkFile::dispatch(config('filesystems.default'), $path.$file_name)->delay(now()->addHours(1));
|
||||
}
|
||||
}
|
||||
|
@ -90,15 +90,9 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
|
||||
Mail::to($this->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
|
||||
} catch (Swift_TransportException $e) {
|
||||
$this->failed($e->getMessage());
|
||||
//$this->entityEmailFailed($e->getMessage());
|
||||
}
|
||||
|
||||
if (count(Mail::failures()) > 0) {
|
||||
$this->logMailError(Mail::failures(), $this->payment->client);
|
||||
} else {
|
||||
// $this->entityEmailSucceeded();
|
||||
} catch (\Exception $e) {
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->payment->client);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -88,13 +88,15 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
|
||||
$mail_obj = (new EntitySentObject($this->invitation, $this->entity_type))->build();
|
||||
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
|
||||
|
||||
//send email
|
||||
Mail::to($this->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
try {
|
||||
Mail::to($this->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
}catch(\Exception $e) {
|
||||
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->entity->client);
|
||||
|
||||
//catch errors
|
||||
if (count(Mail::failures()) > 0) {
|
||||
return $this->logMailError(Mail::failures(), $this->entity->client);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -89,12 +89,15 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
|
||||
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
|
||||
|
||||
//send email
|
||||
Mail::to($this->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
try{
|
||||
Mail::to($this->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->entity->client);
|
||||
|
||||
//catch errors
|
||||
if (count(Mail::failures()) > 0) {
|
||||
return $this->logMailError(Mail::failures(), $this->invoice->client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ use App\Models\Company;
|
||||
use App\Models\SystemLog;
|
||||
use App\Models\User;
|
||||
use App\Providers\MailServiceProvider;
|
||||
use Dacastro4\LaravelGmail\Services\Message\Mail;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@ -77,12 +76,16 @@ class MailRouter extends BaseMailerJob implements ShouldQueue
|
||||
$this->setMailDriver();
|
||||
|
||||
//send email
|
||||
Mail::to($this->to_user->email)
|
||||
->send($this->mailable);
|
||||
|
||||
//catch errors
|
||||
if (count(Mail::failures()) > 0) {
|
||||
$this->logMailError(Mail::failures(), $this->to_user);
|
||||
try {
|
||||
Mail::to($this->to_user->email)
|
||||
->send($this->mailable);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->to_user);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -100,13 +100,17 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
|
||||
$mail_obj->from = [$this->company->owner()->email, $this->company->owner()->present()->name()];
|
||||
|
||||
//send email
|
||||
Mail::to($company_user->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
|
||||
//catch errors
|
||||
if (count(Mail::failures()) > 0) {
|
||||
return $this->logMailError(Mail::failures(), $this->client);
|
||||
try {
|
||||
Mail::to($company_user->user->email)
|
||||
->send(new EntityNotificationMailer($mail_obj));
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->client);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -95,33 +95,15 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
|
||||
|
||||
info("mailing failed with message " . $e->getMessage());
|
||||
event(new PaymentWasEmailedAndFailed($this->payment, $this->company, Mail::failures(), Ninja::eventVars()));
|
||||
$this->failed($e);
|
||||
return $this->logMailError($e->getMessage(), $this->payment->client);
|
||||
|
||||
}
|
||||
|
||||
// if (count(Mail::failures()) > 0) {
|
||||
// info("logging mail failures");
|
||||
// info(print_r(Mail::failures(),1));
|
||||
|
||||
|
||||
// }
|
||||
|
||||
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function failed($exception = null)
|
||||
{
|
||||
info('the job failed');
|
||||
|
||||
$job_failure = new EmailInvoiceFailure();
|
||||
$job_failure->string_metric5 = 'payment';
|
||||
$job_failure->string_metric6 = $exception->getMessage();
|
||||
|
||||
LightLogs::create($job_failure)
|
||||
->batch();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,16 +72,21 @@ class UserEmailChanged extends BaseMailerJob implements ShouldQueue
|
||||
$mail_obj->data = $this->getData();
|
||||
|
||||
//Send email via a Mailable class
|
||||
//
|
||||
try {
|
||||
Mail::to($this->old_email)
|
||||
->send(new UserNotificationMailer($mail_obj));
|
||||
|
||||
Mail::to($this->new_email)
|
||||
->send(new UserNotificationMailer($mail_obj));
|
||||
|
||||
//Catch errors and report.
|
||||
if (count(Mail::failures()) > 0) {
|
||||
return $this->logMailError(Mail::failures(), $this->company);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
||||
$this->failed($e);
|
||||
$this->logMailError($e->getMessage(), $this->company->owner());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function getData()
|
||||
|
Loading…
x
Reference in New Issue
Block a user