Skip to content

Commit 72e2c3e

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: [TwigBridge] Change return type of Symfony\Bridge\Twig\AppVariable::getSession() [mailer] reset $code variable each iteration for prevent wrong codes to be used bug [mailer] fix EsmtpTransport variable $code definition UrlHelper: minor code style fix [Serializer] Looking for DiscriminatorMap on interfaces when the current object also extends from a class [DoctrineBridge][Security] Rename loadUserByUsername tests to loadUserByIdentifier
2 parents 70b7234 + d89611a commit 72e2c3e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Tests/Transport/Smtp/EsmtpTransportTest.php

+22
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,28 @@ public function testSetAuthenticators()
192192
$stream->getCommands()
193193
);
194194
}
195+
196+
public function testConstructorWithEmptyAuthenticator()
197+
{
198+
$stream = new DummyStream();
199+
$transport = new EsmtpTransport(stream: $stream);
200+
$transport->setUsername('testuser');
201+
$transport->setPassword('p4ssw0rd');
202+
$transport->setAuthenticators([]); // if no authenticators defined, then there needs to be a TransportException
203+
204+
$message = new Email();
205+
$message->from('[email protected]');
206+
$message->addTo('[email protected]');
207+
$message->text('.');
208+
209+
try {
210+
$transport->send($message);
211+
$this->fail('Symfony\Component\Mailer\Exception\TransportException to be thrown');
212+
} catch (TransportException $e) {
213+
$this->assertStringStartsWith('Failed to find an authenticator supported by the SMTP server, which currently supports: "plain", "login", "cram-md5", "xoauth2".', $e->getMessage());
214+
$this->assertEquals(504, $e->getCode());
215+
}
216+
}
195217
}
196218

197219
class CustomEsmtpTransport extends EsmtpTransport

Transport/Smtp/EsmtpTransport.php

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ private function handleAuth(array $modes): void
184184
return;
185185
}
186186

187+
$code = null;
187188
$authNames = [];
188189
$errors = [];
189190
$modes = array_map('strtolower', $modes);

0 commit comments

Comments
 (0)