in2code-de / luxletter

Newsletter system for TYPO3
https://www.in2code.de/agentur/typo3-extensions/luxletter/
23 stars 25 forks source link

Sending queue blocked indefinitely: Symfony Mailer throws SMTP error '550 recipient domain may not exist' #137

Closed rr-it closed 1 year ago

rr-it commented 2 years ago

Send the newsletter via SMTP and the "new" Symfony Mailer might throw errors. Then the sending queue is blocked indefinitely, as it tries to re-send the blocked mail and fails again.

Example error: (This one might actually be fixed on the SMTP sender server by disabling "recipient domain verification".)

Ausführung fehlgeschlagen:
550, Expected response code "250/251/252" but got code "550", with message 
"
550-The mail server could not deliver mail to info@non-existing-domain.org.  The 
550-account or domain may not exist, they may be blacklisted, or missing the
550 proper dns entries.

Quick fix for my installation and SMTP server error message: EXT:luxletter/Classes/Mail/SendMail.php

            if ($event->isSend() === true) {
                try {
                    return $mailMessage->send();
                } catch (\Symfony\Component\Mailer\Exception\TransportExceptionInterface $e) {
                    // some error prevented the email sending
                    $debug = $e->getDebug();
                    if (mb_strpos($debug, "550 proper dns entries") !== false) {
                        // non-existent recipient domain
                        return true;
                    }
                }
            }

See https://symfony.com/doc/current/mailer.html#handling-sending-failures

einpraegsam commented 2 years ago

Thx, I think this needs a clean integration into luxletter. I'm open for PR :)

rr-it commented 2 years ago

These codes/error messages are defined in: RFC5321 (RFC2821) SMTP -> SMTP Replies -> 4.2.1 Reply Code Severities and Theory See https://www.rfc-editor.org/rfc/rfc5321#section-4.2.1

5yz Permanent Negative Completion reply The command was not accepted and the requested action did not occur. The SMTP client SHOULD NOT repeat the exact request (in the same sequence). […]

Permanent failures include