Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Mailer] add error code to TransportException #45221

Closed
@tossat

Description

@tossat

Description

It would be nice to have error codes in the TransportException, if the state of the transport is clear.

In our application it is a valid flow to get a 535, if the credentials in cache are not valid anymore -> we trigger a cache update. Currently we have to parse the code from the error message, but the occurance of a 535 in the transport is clear and the error code could be added easily (see example below).

Example

EsmtpTransport.php [186-195]:

    ...
    if (!$authNames) {
        throw new TransportException(sprintf('Failed to find an authenticator supported by the SMTP server, which currently supports: "%s".', implode('", "', $modes)),504); //Unrecognized authentication type
    }

    $message = sprintf('Failed to authenticate on SMTP server with username "%s" using the following authenticators: "%s".', $this->username, implode('", "', $authNames));
    foreach ($errors as $name => $error) {
        $message .= sprintf(' Authenticator "%s" returned "%s".', $name, $error);
    }

    throw new TransportException($message,535); //Authentication credentials invalid
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions