Selaa lähdekoodia

Merge pull request #12766 from stalker314314/streaming-options

Expose Swift Mailer streaming options in config, fixes #12702
tags/v16.0.0alpha1
John Molakvoæ 5 vuotta sitten
vanhempi
commit
6f994be665
No account linked to committer's email address
3 muutettua tiedostoa jossa 33 lisäystä ja 0 poistoa
  1. 7
    0
      config/config.sample.php
  2. 4
    0
      lib/private/Mail/Mailer.php
  3. 22
    0
      tests/lib/Mail/MailerTest.php

+ 7
- 0
config/config.sample.php Näytä tiedosto

@@ -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``.
*

+ 4
- 0
lib/private/Mail/Mailer.php Näytä tiedosto

@@ -259,6 +259,10 @@ class Mailer implements IMailer {
if (!empty($smtpSecurity)) {
$transport->setEncryption($smtpSecurity);
}
$streamingOptions = $this->config->getSystemValue('mail_smtpstreamoptions', []);
if (is_array($streamingOptions) && !empty($streamingOptions)) {
$transport->setStreamOptions($streamingOptions);
}

return $transport;
}

+ 22
- 0
tests/lib/Mail/MailerTest.php Näytä tiedosto

@@ -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', [], ['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', [], 'bar']
]));
$mailer = self::invokePrivate($this->mailer, 'getInstance');
$this->assertEquals(0, count($mailer->getTransport()->getStreamOptions()));
}
}

Loading…
Peruuta
Tallenna