Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

Expose SMTP TLS controls for local relays (#1244)

Ridwan Agudadb11cfc6f420
diff --git a/backend/.env.example b/backend/.env.example
index c5ee655b3..d1db304f7 100644
--- a/backend/.env.example
+++ b/backend/.env.example
@@ -50,6 +50,8 @@ MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
+MAIL_AUTO_TLS=true
+MAIL_VERIFY_PEER=true
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
diff --git a/backend/config/mail.php b/backend/config/mail.php
index 5bb225452..c64277f39 100644
--- a/backend/config/mail.php
+++ b/backend/config/mail.php
@@ -44,6 +44,8 @@ return [
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
+ 'auto_tls' => env('MAIL_AUTO_TLS', true),
+ 'verify_peer' => env('MAIL_VERIFY_PEER', true),
],
'ses' => [
diff --git a/backend/tests/Unit/Configuration/MailConfigurationTest.php b/backend/tests/Unit/Configuration/MailConfigurationTest.php
new file mode 100644
index 000000000..7dbe1d1a9
--- /dev/null
+++ b/backend/tests/Unit/Configuration/MailConfigurationTest.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Tests\Unit\Configuration;
+
+use Illuminate\Mail\MailManager;
+use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
+use Tests\TestCase;
+
+class MailConfigurationTest extends TestCase
+{
+ public function test_smtp_transport_can_disable_opportunistic_starttls(): void
+ {
+ config([
+ 'mail.mailers.smtp' => array_merge(config('mail.mailers.smtp'), [
+ 'auto_tls' => false,
+ 'verify_peer' => false,
+ ]),
+ ]);
+
+ /** @var MailManager $mailManager */
+ $mailManager = app('mail.manager');
+
+ $transport = $mailManager->createSymfonyTransport(config('mail.mailers.smtp'));
+
+ $this->assertInstanceOf(EsmtpTransport::class, $transport);
+ $this->assertFalse($transport->isAutoTls());
+ $this->assertFalse($transport->getStream()->getStreamOptions()['ssl']['verify_peer']);
+ $this->assertFalse($transport->getStream()->getStreamOptions()['ssl']['verify_peer_name']);
+ }
+}
diff --git a/docker/all-in-one/.env.example b/docker/all-in-one/.env.example
index 3a7b4f613..cce1ee6b7 100644
--- a/docker/all-in-one/.env.example
+++ b/docker/all-in-one/.env.example
@@ -34,6 +34,8 @@ MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
+MAIL_AUTO_TLS=true
+MAIL_VERIFY_PEER=true
MAIL_FROM_NAME="Hi Events"
diff --git a/docker/all-in-one/docker-compose.yml b/docker/all-in-one/docker-compose.yml
index 28f912c61..2febdb355 100644
--- a/docker/all-in-one/docker-compose.yml
+++ b/docker/all-in-one/docker-compose.yml
@@ -31,6 +31,8 @@ services:
- MAIL_USERNAME=${MAIL_USERNAME}
- MAIL_PASSWORD=${MAIL_PASSWORD}
- MAIL_ENCRYPTION=${MAIL_ENCRYPTION}
+ - MAIL_AUTO_TLS=${MAIL_AUTO_TLS}
+ - MAIL_VERIFY_PEER=${MAIL_VERIFY_PEER}
- MAIL_FROM_ADDRESS=${MAIL_FROM_ADDRESS}
- MAIL_FROM_NAME=${MAIL_FROM_NAME}
- FILESYSTEM_PUBLIC_DISK=${FILESYSTEM_PUBLIC_DISK}