-
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
Use CRLF for header separation, except sendmail, fixes #23 #24
Conversation
@peterthomassen Thanks for your PR. Can you see differences between PHP8.1 and PHP7.4 on your server? @till You quoted the RFC description in the issue #23. According to the RFC, \r\n is always required. In this PR, there is still a difference between windows OS and other systems. The only difference between this PR and the old code, is that the PHP_EOL isn´t used anymore. I think, i have to test this PR on a windows and on a linux server, to check, whats the exact difference between PHP_EOL, "\n" and "\r\n", on each system. Maybe we can only provide "\r\n" on every system, like the RFC says? My idea is, there is a problem with the PHP_EOL constant on that system constellation (Ubuntu 22.04, PHP 8.1). That could be explain, why this error did not occur earlier. I will test this in the next few days, but i have to setup a test system first. Maybe this could take a few days. |
Unfortunately, I'm not in a position to test PHP 7.4.
The RFC quote is about using CRLF for folding headers (i.e. as a separator for multi-line headers). That's different from what we're discussing, which is the separator between headers (i.e. what's right before the field name). Because that quote doesn't apply there, I didn't generally set |
There is a note at the parameter "additional headers" from the mail() function:
That sound like the problem that @peterthomassen has. Maybe, we should make the CRLF editable via the parameters of the Mail\mail method, instead of changing the general if statement? |
I have the opposite problem. |
@peterthomassen ok. i´m very tired at the moment. But i will check this in the next few days, and give a feedback. Thank you for your contribution. |
@peterthomassen sorry for the long time. but i have to get some things done before i can have a look at this projects again. So i read the issue #23 and this PR again, and still be confused. You´ve written, that the problem occurs on your ubuntu system, because the PHP_EOL was |
No problem about the delay. :-) Oops! You are right, the PR is buggy! I'm glad you caught my mistake. I had misread the My intention was that the separator should be set to I am using a different fix (did not touch the library, but instead I set So it seems like both on Windows and not on Windows,
This is OS-independent. In fact, I had wondered before what the Windows treatment is about, but I had largely ignored it because I don't know much about Windows. But it now seems that on either OS, the same handling is in order. If you agree, I'm happy to fix the PR. |
@peterthomassen thanks for your reply. i am happy about your mistake. i was struggeling about understanding the issue. ;-) @jparise @till what do you think about this solution? alternatively or additionaly we can implement getter and setter for the |
The RFC 822 shows |
@schengawegga Yeah, as I said I am more surprised it took this long for someone to file a bug. |
i took a look on the actual RFC5322. The |
... and I am wondering about the motivation for the commit that introduced the behavior we're now removing. But perhaps that was conditional on circumstances that have changed since then, so the archaeology is hard to do now. (Or perhaps we're missing something ...) |
@peterthomassen yes, that's why i'm not taking the decision lightly either. And want to do some tests on different server OS. |
I think, i found the reason of this commit in a note on PHP mail():
So we can not know, wich MTA is used and we also can not know, if this MTA replaces Maybe at some implementations of Mail_mail the use of So i think, we can not delete this section without running in trouble with other implementations. @peterthomassen @till @jparise @alecpl What do you think about this solution? |
I have no preference which way this is handled, as I already found my own fix. :-) |
I'm afraid I don't recall any additional context beyond what I recorded in the commit message, and it's certainly possible things in the execution environment have changed over the last 20 years. 😉 The qmail detail is interesting because I was definitely using qmail-based systems at the time. For example, I administrated the Horde mailing lists using ezmlm. In general, I would make the default behavior RFC-compliant and allow for site-level configuration to change the |
Thanks for your answers. I think i found a good solution. Since PHP7.2 the
Giving the headers as an array to So i will give the headers array in |
Sounds like a great plan! |
@peterthomassen So, after a few tries, and a lot of thinking and practicing a lot ways of getters, setters and giving the headers array directly to the Giving the headers array directly to the But then i found out that the solution is already there and i think thats the reason, why this bug not be filed after such a long time. Here is the solution code from my test script:
You can set the separator So the solution should be almost there, but a little bit hidden. @peterthomassen can you tell me, if this solution works for you as well? |
@peterthomassen HAHA. I`m sorry. This is the trouble i get into it, when i am developing at 00:15am. That was your solution already. So ignore my question, please. ;-) |
@jparise @till @alecpl What do you think about all that? |
@jparise Thanks. That´s what i thought. So we can forget the idea to implement getter and setter, because it is already there. With this change, we also will not crash any script, wich has been set the When we make this change, we have to write a comment, wich explains this behavior well and give a clear hint to set a separator manually, if needed. Is there a way of giving the callers a hint of this change after Update via composer or log files? What do you think about that plan? |
I think your proposal will only change the default behavior for Windows users. I assume that's a smaller percentage of the total user base. We could address this backward incompatibility by releasing the change under a new major version number. I don't know if there's a more helpful (non-annoying) way to signal the affected users at runtime. |
No, my proposal will change the default behavior for Non-Windows user, like Linux or Mac, because we set |
Ah, I read the I think this is a situation where it would be good to break backwards compatibility to achieve the correct default behavior, but I do think it probably warrants a semver bump, and I'm afraid I don't have a good sense for how disruptive that would be to the user case (if at all). |
It is possible, that the impact of this change will not as big as mentioned. Because it seems that many MTA will replace @jparise what do you think about that solution? |
Got it.
What would that condition look like in practice? After the default is changed, it would only trigger for people who have overridden |
yes |
It seems php's The mail documentation is clear that it should be
The code comment justification is about passing command line arguments - but that does not happen (code). There seems no reason to change |
@aydun thanks for your reply and the tests you've done. I found a behavior of postfix replacing Maybe this would be the reason of this if statement, and maybe postfix fixed this behavior already. So, I am with you to delete this if statement, leave the initial value of @jparise @peterthomassen @ashnazg @aydun do you agree with that? |
@schengawegga - Yes, that makes sense to me. |
b72d3c8
to
e4789e2
Compare
I'm fine with that. I'd propose to add the (The old code also branches depending on whether |
Thanks for the commit. But I see some problems with the Which will be the most of the systems this package runs on. So this notice will spam the error log on every Linux system at every single mail transmission. I think a description in the changelog and the new major release version |
e4789e2
to
5e71c0f
Compare
I agree. I changed the code accordingly. |
@peterthomassen Thank you for this commit. Can you do this in sendmail.php, too? code |
I sure can, but do we know this is the right thing to do? The code comment says: /*
* Because we need to pass message headers to the sendmail program on
* the commandline, we can't guarantee the use of the standard "\r\n"
* separator. Instead, we use the system's native line separator.
*/ Does this argument no longer hold? (It seems to me that this is a different argument than in |
@peterthomassen good point. i will think about that. |
You're right. We have to leave this, because it's passed via the command line. So the OS line separator is necessary. Thank you and all contributers for your efforts. I will merge this in the new 2.0.0 branch. |
No description provided.