I also have same issue, the Mailcow use self-signed certifcate. I've tried add something in extend.php but actually all of them didn't work because they never passthrough to inside instance since Flarum built them self instance.
The only way is hack the flarum/core SMTP driver file both on v1.x and v2.x, here is example on v1.x:
# cat patches/flarum/core/src/Mail/SmtpDriver.php
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Mail;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Validation\Factory;
use Illuminate\Support\MessageBag;
use Swift_SmtpTransport;
use Swift_Transport;
class SmtpDriver implements DriverInterface
{
use ValidatesMailSettings;
public function availableSettings(): array
{
return [
'mail_host' => '', // a hostname, IPv4 address or IPv6 wrapped in []
'mail_port' => '', // a number, defaults to 25
'mail_encryption' => '', // "tls" or "ssl"
'mail_username' => '',
'mail_password' => '',
];
}
public function validate(SettingsRepositoryInterface $settings, Factory $validator): MessageBag
{
return $validator->make($settings->all(), [
'mail_host' => ['required', $this->noWhitespace()],
'mail_port' => ['nullable', 'integer', $this->noWhitespace()],
'mail_encryption' => 'nullable|in:tls,ssl,TLS,SSL',
'mail_username' => ['nullable', 'string', $this->noWhitespace()],
'mail_password' => ['nullable', 'string', $this->noWhitespace()],
])->errors();
}
public function canSend(): bool
{
return true;
}
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport
{
$transport = new Swift_SmtpTransport(
$settings->get('mail_host'),
$settings->get('mail_port'),
$settings->get('mail_encryption') // <-- This actually DIDN'T WORK if you want disable encryption, it ALWAYS use STARTTLS or something like that when available (even encryption is null)!
);
$transport->setUsername($settings->get('mail_username'));
$transport->setPassword($settings->get('mail_password'));
$transport->setStreamOptions([ // Hack start
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
]); // Hack end
return $transport;
}
}
@GreXXL The Flarum team really should address this issue, at the very least by providing a switch in config.php so I don't have to modify core files every single time.