Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
From the patch (to default.settings.php):
/**
* Line endings for e-mail messages
*
* E-mail uses CRLF for line endings. PHP's mail() API function is
* documented to require only LF endings in the message body.
* However, on Windows, mail() behaves differently and it is correct
* to give if CRLF; some MTAs (such as qmail) will refuse to accept
* messages from PHP on Windows if you only supply LF.
*
* This tries to set the correct line ending for your system. If it
* does not work, you can override it.
*/
Comment | File | Size | Author |
---|---|---|---|
#10 | mail-line-endings_4.patch | 2.74 KB | jeffschuler |
#5 | mail-line-endings_3.patch | 2.43 KB | jeffschuler |
#3 | mail-line-endings_2.patch | 3.12 KB | jeffschuler |
mail-line-endings.patch | 3.39 KB | bjaspan | |
Comments
Comment #1
keith.smith CreditAttribution: keith.smith commentedThere is a patch, so CNR.
bjaspan: if you have to reroll for some other reason,
I think "to give if" should be "to get it" maybe?
Comment #2
Robin Monks CreditAttribution: Robin Monks commentedPatch fails to apply to HEAD.
Robin
Comment #3
jeffschulerRe-rolled against current D7 HEAD.
Changed "to give if" to "to give it", and changed double-spaces to singles after sentences in comments.
Comment #4
cburschkaDrupal already has a mechanism to allow settings.php to override system variables. It would be better to use the $conf array and variable_get() instead of creating a new global.
Edit: As for the auto-detection, this would be best done in mail.inc in a constant.
As in:
Then while building the mail:
And in default.settings.php, something like:
Comment #5
jeffschulerThanks Arancaytar, that made sense to me and was helpful.
I've incorporated your suggestions -- suitably, I hope.
Comment #6
dale42Tested on a Windows XP system running XAMPP.
XAMPP includes a copy of sendmail.exe which can be optionally used instead of SMTP/smtp_port option.
I tested pre and post patch with both mail configuration options (SMTP and sendmail_path).
Mail was generated by blocking/unblocking an account.
In both mail configurations, mail worked before the patch and continued to work after the patch.
So although the patch isn't required for this configuration, it didn't break anything, either.
Comment #8
jeffschulerI just re-tested applying to HEAD and had no problem.
I'm setting back to needs review to ask Testbot for another try.
Comment #10
jeffschulerupdated for HEAD
Comment #11
bjaspan CreditAttribution: bjaspan commentedRTBC.
Comment #12
webchickCool. Makes sense to me. Committed to HEAD. Thanks!
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedPlease revert. We don't use our main settings file as a place to do random documentation and overriding. This was mentioned in #4. This should be a regular old pref in a settings page.
Comment #14
moshe weitzman CreditAttribution: moshe weitzman commentedComment #15
webchickI disagree with making this a full-blown setting. But Moshe is right that we don't want to clobber the default.settings.php file with odd-ball settings that only 1/100000000 sites will need to monkey with. It seems like the constant should guess the right thing on 99% of servers.
Incidentally, it's probably about time for one of these http://api.drupal.org/api/globals but for variables for cases exactly like this.
Comment #16
webchickOk, created #620650: Create a variables.php for documenting hidden variables as a follow-up to cover cases like this.
Also reverted the default.settings.php hunk, and adjusted the comment in mail.sending.inc accordingly.
Comment #18
marco68 CreditAttribution: marco68 commentedHi, I report that in my system (win7x64, IIS, php 5.3.2, Drupal 7.12) :
My PHP variables (getted with phpinfo):
_SERVER["windir"] E:\WINDOWS
Note the lower case on variable name_SERVER["SERVER_SOFTWARE"] Microsoft-IIS/6.0
So the proposed patch does't work for me and I cannot send mail without override
$conf['mail_line_endings']
.Without the override outgoing messages contains single
\n
.Regards
Marco
Comment #19
shakyjake CreditAttribution: shakyjake commentedWindows Server 2008 R2 / D7.23 / PHP 5.3.24 / IIS 7.5
This isn't working out-of-the-box for me as both
isset($_SERVER['WINDIR'])
andstrpos($_SERVER['SERVER_SOFTWARE'], 'Win32')
are returning falseIn order to fix it I added the following check to MAIL_LINE_ENDINGS definition-
|| strpos($_SERVER['SERVER_SOFTWARE'], 'IIS/7.5')
Just in case anyone finds themselves in the same situation and comes across this thread.