diff --git a/.env.example b/.env.example index a1f5fc7..2d0e31f 100644 --- a/.env.example +++ b/.env.example @@ -31,8 +31,7 @@ MAIL_PASSWORD=null MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS=null MAIL_FROM_NAME="${APP_NAME}" -MAIL_TO_ADDRESS=null -MAIL_TO_NAME=null +MAIL_ADMIN_ADDRESS=null # SENTRY SENTRY_LARAVEL_DSN= diff --git a/app/Http/Controllers/API/SyncController.php b/app/Http/Controllers/API/SyncController.php index 657353f..3f4c442 100644 --- a/app/Http/Controllers/API/SyncController.php +++ b/app/Http/Controllers/API/SyncController.php @@ -196,14 +196,13 @@ class SyncController extends Controller if (count($noExists) === 0) { $mail = new SendFlyer([ 'body' => $message, - 'from' => $user->email, 'fromName' => $user->firstname . ' ' . $user->lastname, - 'subject' => sprintf("[%s] - %s", \tenant('name'), $subject), + 'subject' => $subject, 'attach' => $attach, 'filesName' => $filesName, ]); - Mail::to($email)->cc($user->email)->queue($mail); + Mail::to($email)->cc($user->email)->send($mail); } else { $mail = new SendFlyerFailed([ 'email' => $email, @@ -213,7 +212,7 @@ class SyncController extends Controller 'noExists' => $noExists ]); - Mail::to($user->email)->queue($mail); + Mail::to($user->email)->send($mail); } //end if return 'OK'; } diff --git a/app/Jobs/Mails/SendTenantDeletedMail.php b/app/Jobs/Mails/SendTenantDeletedMail.php index 0786723..da56791 100644 --- a/app/Jobs/Mails/SendTenantDeletedMail.php +++ b/app/Jobs/Mails/SendTenantDeletedMail.php @@ -39,7 +39,7 @@ class SendTenantDeletedMail implements ShouldQueue */ public function handle(): void { - foreach (config('mail.to.address') as $address) { + foreach (config('mail.admin.address') as $address) { Mail::to($address)->send(new TenantDeleted($this->author, $this->name)); } } diff --git a/app/Mail/SendFlyer.php b/app/Mail/SendFlyer.php index 435cd18..44e1c0d 100644 --- a/app/Mail/SendFlyer.php +++ b/app/Mail/SendFlyer.php @@ -3,10 +3,11 @@ namespace App\Mail; use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -class SendFlyer extends Mailable +class SendFlyer extends Mailable implements ShouldQueue { use Queueable; use SerializesModels; @@ -33,7 +34,7 @@ class SendFlyer extends Mailable public function build(): mixed { return $this - ->from($this->data->from, $this->data->fromName) + ->from(config('mail.from.address'), $this->data->fromName) ->subject($this->data->subject) ->markdown('bo.mails.sendflyer'); } diff --git a/app/Mail/SendFlyerFailed.php b/app/Mail/SendFlyerFailed.php index 225eb19..4f0a460 100644 --- a/app/Mail/SendFlyerFailed.php +++ b/app/Mail/SendFlyerFailed.php @@ -3,10 +3,11 @@ namespace App\Mail; use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -class SendFlyerFailed extends Mailable +class SendFlyerFailed extends Mailable implements ShouldQueue { use Queueable; use SerializesModels; @@ -33,7 +34,6 @@ class SendFlyerFailed extends Mailable public function build(): mixed { return $this - ->from('noreply@ldc.fr', '[APP] ' . config('app.name')) ->subject('[MAIL] Une erreur est survenue') ->view('bo.mails.sendflyerfailed', ['data' => $this->data]); } diff --git a/config/mail.php b/config/mail.php index 7f55939..57122aa 100644 --- a/config/mail.php +++ b/config/mail.php @@ -96,9 +96,8 @@ return [ 'name' => env('MAIL_FROM_NAME', 'Example'), ], - 'to' => [ - 'address' => explode(",", env('MAIL_TO_ADDRESS', 'hello@example.com')), - 'name' => env('MAIL_TO_NAME', 'Example'), + 'admin' => [ + 'address' => explode(",", env('MAIL_ADMIN_ADDRESS', 'hello@example.com')), ], /* diff --git a/manifest.yaml b/manifest.yaml index 2740b1f..226341b 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -23,8 +23,7 @@ data: MAIL_ENCRYPTION: "${APP_MAIL_ENCRYPTION}" MAIL_FROM_ADDRESS: "${APP_MAIL_FROM_ADDRESS}" MAIL_FROM_NAME: "${APP_APP_NAME}" - MAIL_TO_ADDRESS: "${APP_MAIL_TO_ADDRESS}" - MAIL_TO_NAME: "${APP_MAIL_TO_NAME}" + MAIL_ADMIN_ADDRESS: "${APP_MAIL_ADMIN_ADDRESS}" QUEUE_CONNECTION: "database" SENTRY_LARAVEL_DSN: "${APP_SENTRY_LARAVEL_DSN}" LDC_WEB_API_KEY: "${APP_LDC_WEB_API_KEY}"