From 0cbb7c9a3cca2ec1f15b2c3fbc4c4f2cbff086c4 Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Wed, 11 Jun 2025 13:52:55 +0700 Subject: [PATCH] feat(webstatement): tambahkan opsi abaikan validasi sertifikat SSL pada PHPMailer - **Penyesuaian Konfigurasi PHPMailer**: - Menambahkan logika baru untuk mengabaikan validasi sertifikat SSL agar mendukung lingkungan yang menggunakan sertifikat self-signed atau tidak valid. - Menambahkan pengecekan properti konfigurasi `ignore_certificate_errors`. - Konfigurasi tambahan meliputi: - `verify_peer` diatur ke `false`. - `verify_peer_name` diatur ke `false`. - `allow_self_signed` diatur ke `true`. - **Peningkatan Debugging**: - Mengaktifkan mode debug jika aplikasi dalam mode debug (`config('app.debug')`). - **Tujuan Perubahan**: - Memfasilitasi pengelolaan email di lingkungan development atau pengujian. - Mendukung sertifikat SSL non-standar tanpa mengganggu fungsionalitas pengiriman email lainnya. Signed-off-by: Daeng Deni Mardaeni --- app/Services/PHPMailerService.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/Services/PHPMailerService.php b/app/Services/PHPMailerService.php index 78d6b32..bdce4c8 100644 --- a/app/Services/PHPMailerService.php +++ b/app/Services/PHPMailerService.php @@ -107,10 +107,22 @@ class PHPMailerService ) ); - // Debug mode - COMMENTED OUT - // if (config('app.debug')) { - // $this->mailer->SMTPDebug = SMTP::DEBUG_SERVER; - // } + // --- TAMBAHKAN BAGIAN INI UNTUK MENGABAIKAN VALIDASI SERTIFIKAT --- + if (isset($config['ignore_certificate_errors']) && $config['ignore_certificate_errors']) { + $this->mailer->SMTPOptions = [ + 'ssl' => [ + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed' => true, + ], + ]; + } + // --- AKHIR TAMBAHAN --- + + // Debug mode + if (config('app.debug')) { + $this->mailer->SMTPDebug = SMTP::DEBUG_SERVER; + } // Timeout settings $this->mailer->Timeout = config('mail.mailers.phpmailer.timeout', 30);