a-r-m-i-n / mbox

TYPO3 CMS backend module to view mbox file contents, like an email client.
4 stars 1 forks source link

Empty lines in mbox file affect parsing #6

Open izzycole opened 6 months ago

izzycole commented 6 months ago

For some reason, my mbox file has 2 linebreaks after each boundary, which causes MailMessages rendered empty.

I could hotfix it by trimming the messageLines in MailMessage.php:47

fwrite($stream, implode('', $this->messageLines));

to

fwrite($stream, trim(implode('', $this->messageLines)));

maybe that could be implemented generally.

thanks! Sebi

Bildschirmfoto 2024-02-20 um 12 00 49 Bildschirmfoto 2024-02-20 um 12 02 25 Bildschirmfoto 2024-02-20 um 12 02 48
a-r-m-i-n commented 6 months ago

Do you use the shipped T3\Mbox\MboxTransport in your mail configuration?

And it would be interesting to know the exact TYPO3, PHP and mbox extension version, you are using.

izzycole commented 6 months ago

yes i use the shipped class like this

    $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport'] = 'T3\Mbox\MboxTransport';

mbox 2.1.0

TYPO3 Version 11.5.33 Webserver Apache PHP Version 7.4.33 Database (Default) MySQL 10.4.32-MariaDB Application Context Production/Staging Operating System Linux 3.10.0-1160.108.1.el7.x86_64

Is suspect that the 2 emtpy lines are added in MboxTransport.php:57

$mboxEmail = $mboxFromLine . $emailAsString . PHP_EOL . PHP_EOL;
a-r-m-i-n commented 6 months ago

Two line breaks should cause one empty line, not two. For any reason, your mail message ends with a line break, which is not expected. And this causes the two empty lines.

I think instead of adjusting the parser as you suggested, trim($emailAsString) is an easier fix.