Skip to content
Snippets Groups Projects
Commit 72d97b44 authored by Branko Kokanovic's avatar Branko Kokanovic
Browse files

Expose Swift Mailer streaming options in config, fixes #12702

parent cae600d2
No related branches found
No related tags found
No related merge requests found
......@@ -421,6 +421,13 @@ $CONFIG = array(
*/
'mail_send_plaintext_only' => false,
/**
* This depends on ``mail_smtpmode``. Array of additional streams options that
* will be passed to underlying Swift mailer implementation.
* Defaults to an empty array.
*/
'mail_smtpstreamoptions' => array(),
/**
* Which mode is used for sendmail/qmail: ``smtp`` or ``pipe``.
*
......
......@@ -259,6 +259,10 @@ class Mailer implements IMailer {
if (!empty($smtpSecurity)) {
$transport->setEncryption($smtpSecurity);
}
$streamingOptions = $this->config->getSystemValue('mail_smtpstreamoptions', array());
if (is_array($streamingOptions) && count($streamingOptions) > 0) {
$transport->setStreamOptions($streamingOptions);
}
return $transport;
}
......
......@@ -167,4 +167,26 @@ class MailerTest extends TestCase {
$this->assertSame(EMailTemplate::class, get_class($this->mailer->createEMailTemplate('tests.MailerTest')));
}
public function testStreamingOptions() {
$this->config->method('getSystemValue')
->will($this->returnValueMap([
['mail_smtpmode', 'smtp', 'smtp'],
['mail_smtpstreamoptions', array(), array('foo' => 1)]
]));
$mailer = self::invokePrivate($this->mailer, 'getInstance');
$this->assertEquals(1, count($mailer->getTransport()->getStreamOptions()));
$this->assertTrue(isset($mailer->getTransport()->getStreamOptions()['foo']));
}
public function testStreamingOptionsWrongType() {
$this->config->method('getSystemValue')
->will($this->returnValueMap([
['mail_smtpmode', 'smtp', 'smtp'],
['mail_smtpstreamoptions', array(), 'bar']
]));
$mailer = self::invokePrivate($this->mailer, 'getInstance');
$this->assertEquals(0, count($mailer->getTransport()->getStreamOptions()));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment