Fixed ErrorException during email sending

In the original code there is this statement:

Code:
                        // Any error may put us in an inconsistent state, so we need to reset the connection.
                        // Ideally this shouldn't throw anything but it could happen so we just want to swall>
                        // all errors and continue on.
                        try
                        {
                                $transport->stop();
                        }
                        catch (\Throwable $null) {}
                }

Was this added after you posted your fix? The only reason I ask is because its very similar to your "finally { }" statement. I don't know, but I'm getting the same error and presumably this is why I've heard rumors there will be a different mailer software in 2.3. I am not confident with how to apply your fix in the latest XenForo version because of the code I've encountered above (presumably does the same thing)? Otherwise, the issue persists. Seems to happen if the mail server (in this case GSuite/Google Workspaces) thinks its being DDOS'd or something and throws a Try again later error. Then its just like broken pipe 300 times.
 
In the original code there is this statement:

Code:
                        // Any error may put us in an inconsistent state, so we need to reset the connection.
                        // Ideally this shouldn't throw anything but it could happen so we just want to swall>
                        // all errors and continue on.
                        try
                        {
                                $transport->stop();
                        }
                        catch (\Throwable $null) {}
                }

Was this added after you posted your fix? The only reason I ask is because its very similar to your "finally { }" statement. I don't know, but I'm getting the same error and presumably this is why I've heard rumors there will be a different mailer software in 2.3. I am not confident with how to apply your fix in the latest XenForo version because of the code I've encountered above (presumably does the same thing)? Otherwise, the issue persists. Seems to happen if the mail server (in this case GSuite/Google Workspaces) thinks its being DDOS'd or something and throws a Try again later error. Then its just like broken pipe 300 times.

Yes, that code snippet was added in XenForo 2.2.5 after I opened this bug report. The code added by the XenForo team does address the issue my site was facing and we haven't had issues since, but it's possible that you and others participating in this thread might be facing unrelated mailing issues that need to be addressed separately.
 
I switched from 2.2.13 to 2.2.15 and after that (and switch from php 8.1.x to 8.2.x) I become this errors:

I never bevore had thsi error, and I use Xenforo since 1.0

Code:
ErrorException: Email to m.hornschuh123@gmail.com from noreply@zetor-forum.de failed: [E_WARNING] fwrite(): SSL: Broken pipe src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:223
Generiert durch: Unbekanntes Benutzerkonto

Code:
#0 [internal function]: XF::handlePhpError(2, '[E_WARNING] fwr...', '/var/www/vhosts...', 223)
#1 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php(223): fwrite(Resource id #206, 'QUIT
MAIL FROM...')
#2 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php(168): Swift_Transport_StreamBuffer->doCommit('QUIT
MAIL FROM...')
#3 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php(91): Swift_ByteStream_AbstractFilterableInputStream->doWrite('QUIT
MAIL FROM...')
#4 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(327): Swift_ByteStream_AbstractFilterableInputStream->write('MAIL FROM:<boun...')
#5 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(305): Swift_Transport_AbstractSmtpTransport->executeCommand('MAIL FROM:<boun...', Array, Array, true, NULL)
#6 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(385): Swift_Transport_EsmtpTransport->executeCommand('MAIL FROM:<boun...', Array, Array, true)
#7 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(485): Swift_Transport_EsmtpTransport->doMailFromCommand('bounced+a950e2e...')
#8 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(517): Swift_Transport_AbstractSmtpTransport->doMailTransaction(Object(Swift_Message), 'bounced+a950e2e...', Array, Array)
#9 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(206): Swift_Transport_AbstractSmtpTransport->sendTo(Object(Swift_Message), 'bounced+a950e2e...', Array, Array)
#10 src/XF/Mail/Mailer.php(315): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array)
#11 src/XF/Mail/Queue.php(148): XF\Mail\Mailer->send(Object(Swift_Message), Object(XF\Mail\SmtpTransport), Array)
#12 src/XF/Job/MailQueue.php(12): XF\Mail\Queue->run(8)
#13 src/XF/Job/Manager.php(260): XF\Job\MailQueue->run(8)
#14 src/XF/Job/Manager.php(202): XF\Job\Manager->runJobInternal(Array, 8)
#15 src/XF/Job/Manager.php(86): XF\Job\Manager->runJobEntry(Array, 8)
#16 job.php(43): XF\Job\Manager->runQueue(false, 8)
#17 {main}

PHP:
array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(57) "https://www.zetor-forum.de/themen/temperaturanzeige.7008/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

And the same x-times with some other email addresses (67 error messages).

Betwen I see certain times these errors:
Code:
Swift_TransportException: Email to zweidam@web.de from noreply@zetor-forum.de failed: Expected response code 250 but got code "421", with message "421 4.7.0 too many MAIL FROM commands (MAILMAX=10), closing transmission channel " src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:459
Generiert durch: Unbekanntes Benutzerkonto

Code:
#0 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(344): Swift_Transport_AbstractSmtpTransport->assertResponseCode('421 4.7.0 too m...', Array)
#1 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(305): Swift_Transport_AbstractSmtpTransport->executeCommand('MAIL FROM:<boun...', Array, Array, false, NULL)
#2 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(392): Swift_Transport_EsmtpTransport->executeCommand('DATA
', Array, Array)
#3 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(499): Swift_Transport_AbstractSmtpTransport->doDataCommand(Array)
#4 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(517): Swift_Transport_AbstractSmtpTransport->doMailTransaction(Object(Swift_Message), 'bounced+3909fbb...', Array, Array)
#5 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(206): Swift_Transport_AbstractSmtpTransport->sendTo(Object(Swift_Message), 'bounced+3909fbb...', Array, Array)
#6 src/XF/Mail/Mailer.php(315): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array)
#7 src/XF/Mail/Queue.php(148): XF\Mail\Mailer->send(Object(Swift_Message), Object(XF\Mail\SmtpTransport), Array)
#8 src/XF/Job/MailQueue.php(12): XF\Mail\Queue->run(8)
#9 src/XF/Job/Manager.php(260): XF\Job\MailQueue->run(8)
#10 src/XF/Job/Manager.php(202): XF\Job\Manager->runJobInternal(Array, 8)
#11 src/XF/Job/Manager.php(86): XF\Job\Manager->runJobEntry(Array, 8)
#12 job.php(43): XF\Job\Manager->runQueue(false, 8)
#13 {main}

PHP:
array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(88) "https://www.zetor-forum.de/themen/kaufberatung-schlegelmulcher-sichelmulcher.4008/page-2"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Xenforo 2.2.15, PHP 8.2.x, Maria DB 10.x

Anybody a hint to fix this?
Isnt Swiftmailer outdated?
 
I know, but 2.3 is future at this time. ;)

I have made a support ticket and @JoN says it can be a php missconfiguration in php 8.2.x and I should step back to 8.1.x for testing.
This have I done today and will see.

I have 3 Xenforo 2.2.15 runing under same php 8.2.x (3 domains) but only two have this error sporadicly - I will see if php 8.1.x is fixing it and if so, then its to find out what is the reason and what can I do to fix that. :)
 
Top Bottom