diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php index 6694505cf4ef..d145fdc8e2a1 100644 --- a/app/Jobs/Account/CreateAccount.php +++ b/app/Jobs/Account/CreateAccount.php @@ -17,8 +17,12 @@ use App\Jobs\Company\CreateCompany; use App\Jobs\Company\CreateCompanyPaymentTerms; use App\Jobs\Company\CreateCompanyTaskStatuses; use App\Jobs\Company\CreateCompanyToken; +use App\Jobs\Mail\NinjaMailer; +use App\Jobs\Mail\NinjaMailerJob; +use App\Jobs\Mail\NinjaMailerObject; use App\Jobs\User\CreateUser; use App\Jobs\Util\VersionCheck; +use App\Mail\Admin\AccountCreatedObject; use App\Models\Account; use App\Notifications\Ninja\NewAccountCreated; use App\Utils\Ninja; @@ -88,7 +92,16 @@ class CreateAccount $spaa9f78->fresh(); - $sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja(); + //todo implement SLACK notifications + //$sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja(); + + $nmo = new NinjaMailerObject; + $nmo->mailable = new NinjaMailer((new AccountCreatedObject($spaa9f78, $sp035a66))->build()); + $nmo->company = $sp035a66; + $nmo->to_user = $spaa9f78; + $nmo->settings = $sp035a66->settings; + + NinjaMailerJob::dispatchNow($nmo); VersionCheck::dispatchNow(); diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index cbce762bd73c..1d76befe4223 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -67,11 +67,12 @@ class NinjaMailerJob implements ShouldQueue //send email try { + nlog("trying to send"); Mail::to($this->nmo->to_user->email) ->send($this->nmo->mailable); } catch (\Exception $e) { //$this->failed($e); - + nlog("error failed with {$e->getMessage()}"); if ($this->nmo->to_user instanceof ClientContact) { $this->logMailError($e->getMessage(), $this->nmo->to_user->client); } diff --git a/app/Listeners/SendVerificationNotification.php b/app/Listeners/SendVerificationNotification.php index d7747459698f..058130a5947b 100644 --- a/app/Listeners/SendVerificationNotification.php +++ b/app/Listeners/SendVerificationNotification.php @@ -51,7 +51,7 @@ class SendVerificationNotification implements ShouldQueue try { $nmo = new NinjaMailerObject; - $nmo->mailable = new NinjaMailer(new VerifyUserObject($event->user, $event->company)); + $nmo->mailable = new NinjaMailer((new VerifyUserObject($event->user, $event->company))->build()); $nmo->company = $event->company; $nmo->to_user = $event->user; $nmo->settings = $event->company->settings; diff --git a/app/Mail/Admin/AccountCreatedObject.php b/app/Mail/Admin/AccountCreatedObject.php new file mode 100644 index 000000000000..847b15bea549 --- /dev/null +++ b/app/Mail/Admin/AccountCreatedObject.php @@ -0,0 +1,52 @@ +user = $user; + $this->company = $company; + } + + public function build() + { + + $data = [ + 'title' => ctrans('texts.new_signup'), + 'message' => ctrans('texts.new_signup_text', ['user' => $this->user->present()->name(), 'email' => $this->user->email, 'ip' => $this->user->ip]), + 'url' => config('ninja.web_url'), + 'button' => ctrans('texts.account_login'), + 'signature' => $this->company->settings->email_signature, + 'settings' => $this->company->settings, + 'logo' => $this->company->present()->logo(), + ]; + + + $mail_obj = new \stdClass; + $mail_obj->subject = ctrans('texts.new_signup'); + $mail_obj->data = $data; + $mail_obj->markdown = 'email.admin.generic'; + $mail_obj->tag = $this->company->company_key; + + return $mail_obj; + } +} \ No newline at end of file diff --git a/app/Mail/Admin/VerifyUserObject.php b/app/Mail/Admin/VerifyUserObject.php index 4d8c3b29f3d8..f674f59ec46a 100644 --- a/app/Mail/Admin/VerifyUserObject.php +++ b/app/Mail/Admin/VerifyUserObject.php @@ -42,6 +42,8 @@ class VerifyUserObject 'url' => url("/user/confirm/{$this->user->confirmation_code}"), 'button' => ctrans('texts.button_confirmation_message'), 'settings' => $this->company->settings, + 'logo' => $this->company->present()->logo(), + 'signature' => $this->company->settings->email_signature, ];