Skip to content

__toString Messing Up SMTP From Header #243

@mwyres

Description

@mwyres

Weird modification to the "From" line:

$content = "From [email protected]   ".@date("D M d H:i:s Y")."\n";
$content .= stream_get_content(STDIN);
$parser = new MailMimeParser();
$message = $parser->parse($content,FALSE);

<perform actions on $message>

$result .= $message->__toString();

The resulting "From" line in $result comes back with weird additional spaces in the date - (note the weird space in between hours and minutes in the formatted date string?)

From [email protected]  Wed Sep 04 01: 31:55 2024 

Workaround is not to pass the content with the "From" line through the __toString() function, that is:

$content = stream_get_content(STDIN);
$parser = new MailMimeParser();
$message = $parser->parse($content,FALSE);

<perform actions on $message>

$output = $message->__toString();
$result = "From [email protected]   ".@date("D M d H:i:s Y")."\n";
$result .= $output;

This gives the "From" line correctly, without the weird space:

From [email protected]  Wed Sep 04 01:31:55 2024 

Given there is a workaround, this is not a critical issue, but somewhere between the creation of MimeMailParser object, and the output using __toString, the "From" line is being handled weirdly.

Note, this is not the "From:" header from further down - this is the very first line that appears at the top of emails after processing via Postfix, and needs to exist if you are post-processing back through Postfix.

Happy to explain further if this isn't completely clear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions