mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-03-01 11:19:40 +03:00
@@ -65,6 +65,13 @@ class AppServiceProvider extends ServiceProvider
|
||||
URL::forceScheme($isHttps ? 'https' : 'http');
|
||||
}
|
||||
|
||||
// Set SMTP mail driver to use a local domain matching the app domain,
|
||||
// which helps avoid defaulting to a 127.0.0.1 domain
|
||||
if ($appUrl) {
|
||||
$hostName = parse_url($appUrl, PHP_URL_HOST) ?: null;
|
||||
config()->set('mail.mailers.smtp.local_domain', $hostName);
|
||||
}
|
||||
|
||||
// Allow longer string lengths after upgrade to utf8mb4
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
|
||||
@@ -122,6 +122,27 @@ class ConfigTest extends TestCase
|
||||
});
|
||||
}
|
||||
|
||||
public function test_app_url_changes_smtp_ehlo_host_on_mailer()
|
||||
{
|
||||
$getLocalDomain = function (): string {
|
||||
/** @var EsmtpTransport $transport */
|
||||
$transport = Mail::mailer('smtp')->getSymfonyTransport();
|
||||
return $transport->getLocalDomain();
|
||||
};
|
||||
|
||||
$this->runWithEnv(['APP_URL' => ''], function () use ($getLocalDomain) {
|
||||
$this->assertEquals('[127.0.0.1]', $getLocalDomain());
|
||||
});
|
||||
|
||||
$this->runWithEnv(['APP_URL' => 'https://example.com/cats/dogs'], function () use ($getLocalDomain) {
|
||||
$this->assertEquals('example.com', $getLocalDomain());
|
||||
});
|
||||
|
||||
$this->runWithEnv(['APP_URL' => 'http://beans.cat.example.com'], function () use ($getLocalDomain) {
|
||||
$this->assertEquals('beans.cat.example.com', $getLocalDomain());
|
||||
});
|
||||
}
|
||||
|
||||
public function test_non_null_mail_encryption_options_enforce_smtp_scheme()
|
||||
{
|
||||
$this->checkEnvConfigResult('MAIL_ENCRYPTION', 'tls', 'mail.mailers.smtp.require_tls', true);
|
||||
|
||||
Reference in New Issue
Block a user