mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Merge pull request #6059 from turbo124/v5-develop
Fixes for mail drivers
This commit is contained in:
commit
27036dc71d
@ -793,9 +793,8 @@ class InvoiceController extends BaseController
|
|||||||
$contact = $invitation->contact;
|
$contact = $invitation->contact;
|
||||||
$invoice = $invitation->invoice;
|
$invoice = $invitation->invoice;
|
||||||
|
|
||||||
$file = $invoice->service()->getInvoicePdf($contact);
|
$file = $invoice->pdf_file_path($invitation);
|
||||||
|
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||||
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
|
|
||||||
public $company;
|
public $company;
|
||||||
|
|
||||||
|
private $mailer;
|
||||||
|
|
||||||
public function __construct(NinjaMailerObject $nmo, bool $override = false)
|
public function __construct(NinjaMailerObject $nmo, bool $override = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -108,7 +110,8 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
try {
|
try {
|
||||||
nlog("trying to send to {$this->nmo->to_user->email} ". now()->toDateTimeString());
|
nlog("trying to send to {$this->nmo->to_user->email} ". now()->toDateTimeString());
|
||||||
|
|
||||||
Mail::to($this->nmo->to_user->email)
|
Mail::mailer($this->mailer)
|
||||||
|
->to($this->nmo->to_user->email)
|
||||||
->send($this->nmo->mailable);
|
->send($this->nmo->mailable);
|
||||||
|
|
||||||
LightLogs::create(new EmailSuccess($this->nmo->company->company_key))
|
LightLogs::create(new EmailSuccess($this->nmo->company->company_key))
|
||||||
@ -151,18 +154,19 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
{
|
{
|
||||||
/* Singletons need to be rebooted each time just in case our Locale is changing*/
|
/* Singletons need to be rebooted each time just in case our Locale is changing*/
|
||||||
App::forgetInstance('translator');
|
App::forgetInstance('translator');
|
||||||
App::forgetInstance('mail.manager'); //singletons must be destroyed!
|
// App::forgetInstance('mail.manager'); //singletons must be destroyed!
|
||||||
App::forgetInstance('mailer');
|
// App::forgetInstance('mailer');
|
||||||
App::forgetInstance('laravelgmail');
|
// App::forgetInstance('laravelgmail');
|
||||||
$t = app('translator');
|
$t = app('translator');
|
||||||
/* Inject custom translations if any exist */
|
/* Inject custom translations if any exist */
|
||||||
$t->replace(Ninja::transformTranslations($this->nmo->settings));
|
$t->replace(Ninja::transformTranslations($this->nmo->settings));
|
||||||
|
|
||||||
switch ($this->nmo->settings->email_sending_method) {
|
switch ($this->nmo->settings->email_sending_method) {
|
||||||
case 'default':
|
case 'default':
|
||||||
//config(['mail.driver' => config('mail.default')]);
|
$this->mailer = config('mail.default');
|
||||||
break;
|
break;
|
||||||
case 'gmail':
|
case 'gmail':
|
||||||
|
$this->mailer = 'gmail';
|
||||||
$this->setGmailMailer();
|
$this->setGmailMailer();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -204,8 +208,8 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
* just for this request.
|
* just for this request.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
config(['mail.driver' => 'gmail']);
|
// config(['mail.driver' => 'gmail']);
|
||||||
(new MailServiceProvider(app()))->register();
|
// (new MailServiceProvider(app()))->register();
|
||||||
|
|
||||||
$token = $user->oauth_user_token->access_token;
|
$token = $user->oauth_user_token->access_token;
|
||||||
|
|
||||||
|
@ -1,4 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
@ -33,9 +42,9 @@ class MailCssInlinerServiceProvider extends ServiceProvider
|
|||||||
return new CssInlinerPlugin([]);
|
return new CssInlinerPlugin([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// $this->app->afterResolving('mail.manager', function (MailManager $mailManager) {
|
$this->app->afterResolving('mail.manager', function (MailManager $mailManager) {
|
||||||
// $mailManager->getSwiftMailer()->registerPlugin($this->app->make(CssInlinerPlugin::class));
|
$mailManager->getSwiftMailer()->registerPlugin($this->app->make(CssInlinerPlugin::class));
|
||||||
// return $mailManager;
|
return $mailManager;
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
@ -24,6 +33,7 @@ class MailServiceProvider extends MailProvider
|
|||||||
|
|
||||||
protected function registerIlluminateMailer()
|
protected function registerIlluminateMailer()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->app->singleton('mail.manager', function($app) {
|
$this->app->singleton('mail.manager', function($app) {
|
||||||
return new GmailTransportManager($app);
|
return new GmailTransportManager($app);
|
||||||
});
|
});
|
||||||
@ -32,7 +42,7 @@ class MailServiceProvider extends MailProvider
|
|||||||
return $app->make('mail.manager')->mailer();
|
return $app->make('mail.manager')->mailer();
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->app['mail.manager']->extend('postmark', function () {
|
$this->app['mail.manager']->extend('cocopostmark', function () {
|
||||||
|
|
||||||
return new PostmarkTransport(
|
return new PostmarkTransport(
|
||||||
$this->guzzle(config('postmark.guzzle', [])),
|
$this->guzzle(config('postmark.guzzle', [])),
|
||||||
@ -41,10 +51,6 @@ class MailServiceProvider extends MailProvider
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->app->afterResolving('mail.manager', function (GmailTransportManager $mailManager) {
|
|
||||||
$mailManager->getSwiftMailer()->registerPlugin($this->app->make(CssInlinerPlugin::class));
|
|
||||||
return $mailManager;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function guzzle(array $config): HttpClient
|
protected function guzzle(array $config): HttpClient
|
||||||
|
@ -73,6 +73,9 @@ return [
|
|||||||
'gmail' => [
|
'gmail' => [
|
||||||
'transport' => 'gmail',
|
'transport' => 'gmail',
|
||||||
],
|
],
|
||||||
|
'cocopostmark' => [
|
||||||
|
'transport' => 'cocopostmark',
|
||||||
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user