diff --git a/app/Constants.php b/app/Constants.php index 05f5b61e4ffd..e43c71fd9d1a 100644 --- a/app/Constants.php +++ b/app/Constants.php @@ -3,7 +3,7 @@ if (!defined('APP_NAME')) { define('APP_NAME', env('APP_NAME', 'Invoice Ninja')); - define('CONTACT_EMAIL', env('MAIL_FROM_ADDRESS')); + define('CONTACT_EMAIL', env('MAIL_FROM_ADDRESS', env('MAIL_USERNAME'))); define('CONTACT_NAME', env('MAIL_FROM_NAME')); define('SITE_URL', env('APP_URL')); diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index b063c97e1eb0..da46d1498a94 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -19,7 +19,7 @@ use App\Models\Payment; use App\Models\TaxRate; use App\Models\InvoiceDesign; use App\Models\Activity; -use App\Ninja\Mailers\ContactMailer as Mailer; +use App\Jobs\SendInvoiceEmail; use App\Ninja\Repositories\InvoiceRepository; use App\Ninja\Repositories\ClientRepository; use App\Ninja\Repositories\DocumentRepository; @@ -33,7 +33,6 @@ use App\Http\Requests\UpdateInvoiceRequest; class InvoiceController extends BaseController { - protected $mailer; protected $invoiceRepo; protected $clientRepo; protected $documentRepo; @@ -42,11 +41,10 @@ class InvoiceController extends BaseController protected $recurringInvoiceService; protected $entityType = ENTITY_INVOICE; - public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, InvoiceService $invoiceService, DocumentRepository $documentRepo, RecurringInvoiceService $recurringInvoiceService, PaymentService $paymentService) + public function __construct(InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, InvoiceService $invoiceService, DocumentRepository $documentRepo, RecurringInvoiceService $recurringInvoiceService, PaymentService $paymentService) { // parent::__construct(); - $this->mailer = $mailer; $this->invoiceRepo = $invoiceRepo; $this->clientRepo = $clientRepo; $this->invoiceService = $invoiceService; @@ -459,7 +457,8 @@ class InvoiceController extends BaseController if ($invoice->is_recurring) { $response = $this->emailRecurringInvoice($invoice); } else { - $response = $this->mailer->sendInvoice($invoice, false, $pdfUpload); + $this->dispatch(new SendInvoiceEmail($invoice, false, $pdfUpload)); + return true; } if ($response === true) { @@ -489,7 +488,8 @@ class InvoiceController extends BaseController if ($invoice->isPaid()) { return true; } else { - return $this->mailer->sendInvoice($invoice); + $this->dispatch(new SendInvoiceEmail($invoice)); + return true; } } diff --git a/app/Jobs/Job.php b/app/Jobs/Job.php new file mode 100644 index 000000000000..cd1bae1ceb3d --- /dev/null +++ b/app/Jobs/Job.php @@ -0,0 +1,47 @@ +sendTo( + config('queue.failed.notify_email'), + config('mail.from.address'), + config('mail.from.name'), + config('queue.failed.notify_subject', trans('texts.job_failed', ['name'=>$this->jobName])), + 'job_failed', + [ + 'name' => $this->jobName, + ] + ); + } + + $logger->error( + trans('texts.job_failed', ['name' => $this->jobName]) + ); + } + */ +} diff --git a/app/Jobs/SendInvoiceEmail.php b/app/Jobs/SendInvoiceEmail.php new file mode 100644 index 000000000000..8194a1c95684 --- /dev/null +++ b/app/Jobs/SendInvoiceEmail.php @@ -0,0 +1,73 @@ +invoice = $invoice; + $this->reminder = $reminder; + $this->pdfString = $pdfString; + } + + /** + * Execute the job. + * + * @param ContactMailer $mailer + */ + public function handle(ContactMailer $mailer) + { + $mailer->sendInvoice($this->invoice, $this->reminder, $this->pdfString); + } + + /** + * Handle a job failure. + * + * @param ContactMailer $mailer + * @param Logger $logger + */ + /* + public function failed(ContactMailer $mailer, Logger $logger) + { + $this->jobName = $this->job->getName(); + + parent::failed($mailer, $logger); + } + */ +} diff --git a/config/app.php b/config/app.php index 9e1784529047..84fabfb28d5d 100644 --- a/config/app.php +++ b/config/app.php @@ -119,7 +119,7 @@ return [ */ 'Illuminate\Auth\AuthServiceProvider', 'Collective\Html\HtmlServiceProvider', - 'Collective\Bus\BusServiceProvider', + 'Illuminate\Bus\BusServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Cookie\CookieServiceProvider',