kartolo/direct_mail

Analyze bounce mail Task - 503 crash on particular bounce Mails

rnakielski opened this issue · 0 comments

using dm 9.5.1, t3 11.5, php 7.4

The Analyze bounce mail Task cashes with the following message

Core: Exception handler (WEB): Uncaught TYPO3 Exception: trim() expects parameter 1 to be string, null given | TypeError thrown in file /var/www/public/typo3conf/ext/direct_mail/Classes/Utility/ReadmailUtility.php in line 229.

This does happen when analysing Bounce Mails like this

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

dings@dangs.de
mailbox is full: retry timeout exceeded

------ This is a copy of the message, including all the headers. ------
...

Analysing the ReadmailUtility Class I figured out that it will crash at all QMAIL Bounce mails that do not contain the string ">:" in the content like in the Bounce mail above - others contain text like <klappt@nicht.de>: Recipient address rejected: User unknown - that will work.

direct_mail/Classes/Utility/ReadmailUtility.php Line 228

$parts = explode('>:', $cp['content'], 2);
$cp['reason_text'] = trim($parts[1])?trim($parts[1]):$cp['content'];

When there is no ">:" in the content $parts[1] is null and cannot be trimmed - the ? operator seems not to check this.

Following Change works:
Line 229
from: $cp['reason_text'] = trim($parts[1])?trim($parts[1]):$cp['content'];
to: $cp['reason_text'] = trim($parts[1]??$cp['content']);

The ?? operator checks for null and the trim is done anyway