fix: Fix mail config - Close #63

This commit is contained in:
Vincent BRIDIER 2025-09-24 11:27:55 +02:00
parent 941c10b6f2
commit 7b8000f9ba
7 changed files with 13 additions and 16 deletions

View file

@ -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=

View file

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

View file

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

View file

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

View file

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

View file

@ -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')),
],
/*

View file

@ -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}"