1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Merge pull request #4929 from turbo124/v5-develop

Gmail Multimailer
This commit is contained in:
David Bomba 2021-02-17 13:22:08 +11:00 committed by GitHub
commit a7a5a90477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 27 deletions

View File

@ -42,19 +42,14 @@ class GmailTransport extends Transport
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
/* For some reason the Injected Mail class carries cached tokens, so we need to reinit the Mail class*/
$this->gmail = null;
$this->gmail = new Mail;
/*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);
@ -63,7 +58,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 +77,6 @@ class GmailTransport extends Transport
}
$this->gmail->send();
$this->sendPerformed($message);

View File

@ -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();
}

View File

@ -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);
});
}