-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong header separator #23
Comments
@peterthomassen Want to make a PR and add a test? What you say makes sense, more surprised no one hit this before. |
Sure. I had not opened a PR because the original commit that added the |
The commit you linked seems to do it right. Did you mean a later one? I am on my phone and can't look. |
@jparise has written, that we can't guarantee the use of \r\n on every system. It looks to me like he was not sure if any other system uses only \n in Mail headers. So I think, we should do some tests with a Linux and a windows system. @peterthomassen please make a PR and I will merge it into a branch, so we can test it on a bunch of system. |
I was just confused this is even up for debate:
(source) — CRLF is |
@till 👍 thanks |
Someone should test whether this is gonna work with PHP < 8. There's been some changes regarding this over time, e.g. https://bugs.php.net/bug.php?id=47983 |
@alecpl Thanks for your input. I will test this, when i do some tests on different server OS. |
To follow |
mail()
documentation says:However,
Mail_mail
sets the header separator toPHP_EOL
(if that constant is defined). On my system, this is\n
(in contrast to whatmail()
expects).As a result, on my system (Ubuntu 22.04, PHP 8.1), additional headers are not properly delivered: All but the first header are indented with a single space, making them a continuation of the previous header. Example message (as actually delivered):
This results in fully broken email display (MIME boundary does not work, Bcc header malformed and thus retained as plaintext, ...). -- Note that the first header (
MIME-Version
) does not have the space.I cannot tell at which point (after calling
mail()
) these spaces get inserted. But I can tell thatMail_mail
's practice of usingPHP_EOL
(\n
) as a separator when passingadditional_headers
tomail()
is in contradiction to the docs, which say that\r\n
should be used.And indeed when I override
->sep = "\r\n"
on myMail_mail
instance, the problem goes away.As things work as described in the
mail()
documentation, I think that the logic for settingsep
is flawed, and\r\n
should be used exclusively.The text was updated successfully, but these errors were encountered: