From 76f57387dc5c763a35019ece7198ade1385567c3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 Feb 2021 13:20:25 +1100 Subject: [PATCH] Fixes for multi-mailer gmail implementation --- app/Helpers/Mail/GmailTransport.php | 10 +--------- app/Jobs/Entity/EmailEntity.php | 13 ------------- app/Jobs/Mail/NinjaMailerJob.php | 4 +--- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/app/Helpers/Mail/GmailTransport.php b/app/Helpers/Mail/GmailTransport.php index 7d12362367..135bb14d40 100644 --- a/app/Helpers/Mail/GmailTransport.php +++ b/app/Helpers/Mail/GmailTransport.php @@ -45,17 +45,10 @@ class GmailTransport extends Transport /*We should nest the token in the message and then discard it as needed*/ $token = $message->getHeaders()->get('GmailToken')->getValue(); - $user_id = $message->getHeaders()->get('UserId')->getValue(); - - LaravelGmail::setUserId($user_id); - - nlog("gmail transporter token = {$token}"); $message->getHeaders()->remove('GmailToken'); $message->getHeaders()->remove('UserId'); - nlog("inside gmail sender with token {$token}"); - $this->beforeSendPerformed($message); $this->gmail->using($token); @@ -63,7 +56,7 @@ class GmailTransport extends Transport $this->gmail->from($message->getFrom()); $this->gmail->subject($message->getSubject()); $this->gmail->message($message->getBody()); - //$this->gmail->message($message->toString()); + $this->gmail->cc($message->getCc()); $this->gmail->bcc($message->getBcc()); @@ -82,7 +75,6 @@ class GmailTransport extends Transport } - $this->gmail->send(); $this->sendPerformed($message); diff --git a/app/Jobs/Entity/EmailEntity.php b/app/Jobs/Entity/EmailEntity.php index 3c35ba56d5..b4d8ca9737 100644 --- a/app/Jobs/Entity/EmailEntity.php +++ b/app/Jobs/Entity/EmailEntity.php @@ -116,19 +116,6 @@ class EmailEntity implements ShouldQueue NinjaMailerJob::dispatch($nmo); - // try { - // Mail::to($this->invitation->contact->email, $this->invitation->contact->present()->name()) - // ->send( - // new TemplateEmail( - // $this->email_entity_builder, - // $this->invitation->contact - // ) - // ); - // } catch (\Exception $e) { - // $this->entityEmailFailed($e->getMessage()); - // $this->logMailError($e->getMessage(), $this->entity->client); - // } - /* Mark entity sent */ $this->entity->service()->markSent()->save(); } diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 048c877871..2f858564a9 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -153,14 +153,12 @@ class NinjaMailerJob implements ShouldQueue (new MailServiceProvider(app()))->register(); $token = $user->oauth_user_token->access_token; - $user_id = $user->oauth_user_id; $this->nmo ->mailable ->from($user->email, $user->present()->name()) - ->withSwiftMessage(function ($message) use($token, $user_id) { + ->withSwiftMessage(function ($message) use($token) { $message->getHeaders()->addTextHeader('GmailToken', $token); - $message->getHeaders()->addTextHeader('UserId', $user_id); }); }