Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SmtpTransport.php

function SmtpTransport::assertResponseCode

Throws

TransportException if a response code is incorrect

2 calls to SmtpTransport::assertResponseCode()
SmtpTransport::executeCommand in vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php
Runs a command against the stream, expecting the given response codes.
SmtpTransport::start in vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php

File

vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php, line 329

Class

SmtpTransport
Sends emails over SMTP.

Namespace

Symfony\Component\Mailer\Transport\Smtp

Code

private function assertResponseCode(string $response, array $codes) : void {
    if (!$codes) {
        throw new LogicException('You must set the expected response code.');
    }
    [
        $code,
    ] = sscanf($response, '%3d');
    $valid = \in_array($code, $codes);
    if (!$valid || !$response) {
        $codeStr = $code ? \sprintf('code "%s"', $code) : 'empty code';
        $responseStr = $response ? \sprintf(', with message "%s"', trim($response)) : '';
        throw new UnexpectedResponseException(\sprintf('Expected response code "%s" but got ', implode('/', $codes)) . $codeStr . $responseStr . '.', $code ?: 0);
    }
}
RSS feed
Powered by Drupal