From e85009f5e1dcb5365c1311f3c17c25a08e00f94a Mon Sep 17 00:00:00 2001 From: didier Date: Mon, 21 Oct 2024 16:33:10 +0200 Subject: [PATCH 1/2] improve mail parameters --- .env.example | 7 ++++--- app/Console/Commands/SendNotifications.php | 17 ++++++++--------- .../Controllers/ConfigurationController.php | 17 +++++++++-------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.env.example b/.env.example index e1353e9..3094143 100644 --- a/.env.example +++ b/.env.example @@ -23,11 +23,12 @@ SESSION_LIFETIME=120 MAIL_HOST='smtp.localhost' MAIL_PORT=2525 MAIL_AUTH=true -MAIL_SMTP_SECURE='ssl' +MAIL_SMTP_SECURE='ssl' # 'ssl', 'tls' or null +MAIL_SMTP_AUTO_TLS=false # true / false MAIL_USERNAME= MAIL_PASSWORD= # MAIL_DKIM_DOMAIN = 'admin.local'; # MAIL_DKIM_PRIVATE = '/path/to/private/key'; -# MAIL_DKIM_SELECTOR = 'default'; // Match your DKIM DNS selector -# MAIL_DKIM_PASSPHRASE = ''; // Only if your key has a passphrase +# MAIL_DKIM_SELECTOR = 'default'; # Match your DKIM DNS selector +# MAIL_DKIM_PASSPHRASE = ''; # Only if your key has a passphrase diff --git a/app/Console/Commands/SendNotifications.php b/app/Console/Commands/SendNotifications.php index c1c8d27..3c0c199 100644 --- a/app/Console/Commands/SendNotifications.php +++ b/app/Console/Commands/SendNotifications.php @@ -61,15 +61,14 @@ public function handle() try { // Server settings - $mail->isSMTP(); // Use SMTP - $mail->Host = env('MAIL_HOST'); // Set the SMTP server - $mail->SMTPAuth = env('MAIL_AUTH'); // Enable SMTP authentication - $mail->Username = env('MAIL_USERNAME'); // SMTP username - $mail->Password = env('MAIL_PASSWORD'); // SMTP password - $mail->SMTPSecure = env('MAIL_SMTPSECURE',false); // Enable TLS encryption, `ssl` also accepted - if ($mail->SMTPSecure==false) - $mail->SMTPAutoTLS=false; - $mail->Port = env('MAIL_PORT'); // TCP port to connect to + $mail->isSMTP(); // Use SMTP + $mail->Host = env('MAIL_HOST'); // Set the SMTP server + $mail->SMTPAuth = env('MAIL_AUTH'); // Enable SMTP authentication + $mail->Username = env('MAIL_USERNAME'); // SMTP username + $mail->Password = env('MAIL_PASSWORD'); // SMTP password + $mail->SMTPSecure = env('MAIL_SMTP_SECURE',false); // Enable TLS encryption, `ssl` also accepted + $mail->SMTPAutoTLS = env('MAIL_SMTP_AUTO_TLS'); // Enable auto TLS + $mail->Port = env('MAIL_PORT'); // TCP port to connect to // Loop on all users $users = User::all(); diff --git a/app/Http/Controllers/ConfigurationController.php b/app/Http/Controllers/ConfigurationController.php index 5b1aba8..da26184 100644 --- a/app/Http/Controllers/ConfigurationController.php +++ b/app/Http/Controllers/ConfigurationController.php @@ -75,14 +75,15 @@ public function save(Request $request) try { // Server settings $mail->isSMTP(); // Use SMTP - $mail->Host = env('MAIL_HOST'); // Set the SMTP server - $mail->SMTPAuth = env('MAIL_AUTH'); // Enable SMTP authentication - $mail->Username = env('MAIL_USERNAME'); // SMTP username - $mail->Password = env('MAIL_PASSWORD'); // SMTP password - $mail->SMTPSecure = env('MAIL_SMTPSECURE',false); // Enable TLS encryption, `ssl` also accepted - if ($mail->SMTPSecure==false) - $mail->SMTPAutoTLS=false; - $mail->Port = env('MAIL_PORT'); // TCP port to connect to + // Server settings + $mail->isSMTP(); // Use SMTP + $mail->Host = env('MAIL_HOST'); // Set the SMTP server + $mail->SMTPAuth = env('MAIL_AUTH'); // Enable SMTP authentication + $mail->Username = env('MAIL_USERNAME'); // SMTP username + $mail->Password = env('MAIL_PASSWORD'); // SMTP password + $mail->SMTPSecure = env('MAIL_SMTP_SECURE',false); // Enable TLS encryption, `ssl` also accepted + $mail->SMTPAutoTLS = env('MAIL_SMTP_AUTO_TLS'); // Enable auto TLS + $mail->Port = env('MAIL_PORT'); // TCP port to connect to // Recipients $mail->setFrom($mail_from); From 73d7dca99b0d1f63983f9605793c756ddedea633 Mon Sep 17 00:00:00 2001 From: didier Date: Mon, 21 Oct 2024 19:16:44 +0200 Subject: [PATCH 2/2] mail documentation --- .env.ci | 1 + INSTALL.debian.fr.md | 1 + INSTALL.debian.md | 1 + INSTALL.fr.md | 1 + INSTALL.md | 1 + 5 files changed, 5 insertions(+) diff --git a/.env.ci b/.env.ci index 815bbae..5e38d14 100644 --- a/.env.ci +++ b/.env.ci @@ -23,6 +23,7 @@ MAIL_HOST=sandbox.smtp.mailtrap.io MAIL_PORT=2525 MAIL_AUTH=true MAIL_SMTP_SECURE='ssl' +MAIL_SMTP_AUTO_TLS=false MAIL_USERNAME= MAIL_PASSWORD= diff --git a/INSTALL.debian.fr.md b/INSTALL.debian.fr.md index 667e849..ccf963e 100644 --- a/INSTALL.debian.fr.md +++ b/INSTALL.debian.fr.md @@ -193,6 +193,7 @@ Vous devez configurer l'accès au serveur SMTP dans .env MAIL_PORT=2525 MAIL_AUTH=true MAIL_SMTP_SECURE='ssl' + MAIL_SMTP_AUTO_TLS=false MAIL_USERNAME= MAIL_PASSWORD= diff --git a/INSTALL.debian.md b/INSTALL.debian.md index b0a1914..b0da43e 100644 --- a/INSTALL.debian.md +++ b/INSTALL.debian.md @@ -206,6 +206,7 @@ You have to configure the SMTP server access in .env MAIL_PORT=2525 MAIL_AUTH=true MAIL_SMTP_SECURE='ssl' + MAIL_SMTP_AUTO_TLS=false MAIL_USERNAME= MAIL_PASSWORD= diff --git a/INSTALL.fr.md b/INSTALL.fr.md index 93af42f..3cd49c5 100644 --- a/INSTALL.fr.md +++ b/INSTALL.fr.md @@ -196,6 +196,7 @@ Vous devez configurer l'accès au serveur SMTP dans .env MAIL_PORT=2525 MAIL_AUTH=true MAIL_SMTP_SECURE='ssl' + MAIL_SMTP_AUTO_TLS=false MAIL_USERNAME= MAIL_PASSWORD= diff --git a/INSTALL.md b/INSTALL.md index 9bd7e0d..f78fca8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -192,6 +192,7 @@ You have to configure the SMTP server access in .env MAIL_PORT=2525 MAIL_AUTH=true MAIL_SMTP_SECURE='ssl' + MAIL_SMTP_AUTO_TLS=false MAIL_USERNAME= MAIL_PASSWORD=