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

Skip to content

[Mailer] Delivery fails but actual SMTP response is not reported #40414

Closed
@LuKePicci

Description

@LuKePicci

Symfony version(s) affected: 5.2

Description
Proper duplicate of #32148 Look at there for background. Actual issue is that the SMTP server gives a non-empty error/unexpected response but symfony does not catch it properly and outputs this misleading error:

request.CRITICAL: Uncaught PHP Exception Symfony\Component\Mailer\Exception\TransportException: "Expected response code "250" but got an empty response." at /home/site/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php line 300 {"exception":"[object] (Symfony\Component\Mailer\Exception\TransportException(code: 0): Expected response code "250" but got an empty response. at /home/site/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php:300)"} []

while the real one is different and certainly not an empty response. In my peculiar case the error was:

421 4.7.0 Try again later, closing connection. (EHLO) n18sm285960wrm.12 - gsmtp

Please note the reason for the above SMTP message to occur is out of scope here and I already managed to workaround it.
You should consider this issue as solved as soon as you get that 421 message catched and reported in php logs.

How to reproduce
A sufficient condition to reproduce is to use symfony mailer with this DSN: smtp://smtp-relay.gmail.com:587
The SMTP server will respond with 421 error message because of another symfony bug which makes symfony 5.2 using a bad default local_domain ( [127.0.0.1] in my case ) in EHLO command.
You don't need to subscribe or configure any gsuite smtp relay for the bug to reproduce.

Additional context
How to debug:

    /**
     * Runs a command against the stream, expecting the given response codes.
     *
     * @param int[] $codes
     *
     * @return string The server response
     *
     * @throws TransportException when an invalid response if received
     *
     * @internal
     */
    public function executeCommand(string $command, array $codes): string
    {
        $this->stream->write($command);
dump($command);
        $response = $this->getFullResponse();
dump($response);
        $this->assertResponseCode($response, $codes);

        return $response;
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions