diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-02 02:37:36 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-02 02:37:36 +0000 |
commit | b5674375009f9b9ca5c1e5313116af0f97a63b16 (patch) | |
tree | 9a35310940abcc6e5dfda925c7df3ed86b9693c1 | |
parent | 7353d5da626649d62ff292e4129727c6f73deaeb (diff) | |
download | brdo-b5674375009f9b9ca5c1e5313116af0f97a63b16.tar.gz brdo-b5674375009f9b9ca5c1e5313116af0f97a63b16.tar.bz2 |
#239825 by jeffschuler and bjaspan: Add support for OS-specific line endings on e-mails.
-rw-r--r-- | includes/mail.inc | 6 | ||||
-rw-r--r-- | modules/system/mail.sending.inc | 7 | ||||
-rw-r--r-- | sites/default/default.settings.php | 9 |
3 files changed, 19 insertions, 3 deletions
diff --git a/includes/mail.inc b/includes/mail.inc index 4b3706188..92de9bf6d 100644 --- a/includes/mail.inc +++ b/includes/mail.inc @@ -7,6 +7,12 @@ */ /** + * Auto-detect appropriate line endings for e-mails. + * $conf['mail_line_endings'] will override this setting. + */ +define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE ? "\r\n" : "\n"); + +/** * Compose and optionally send an e-mail message. * * Sending an e-mail works with defining an e-mail template (subject, text diff --git a/modules/system/mail.sending.inc b/modules/system/mail.sending.inc index 96db60bb6..c0f0738ad 100644 --- a/modules/system/mail.sending.inc +++ b/modules/system/mail.sending.inc @@ -45,12 +45,13 @@ class DefaultMailSystem implements MailSystemInterface { foreach ($message['headers'] as $name => $value) { $mimeheaders[] = $name . ': ' . mime_header_encode($value); } + $line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS); return mail( $message['to'], mime_header_encode($message['subject']), - // Note: e-mail uses CRLF for line-endings, but PHP's API requires LF. - // They will appear correctly in the actual e-mail that is sent. - str_replace("\r", '', $message['body']), + // Note: e-mail uses CRLF for line-endings. PHP's API requires LF + // on Unix and CRLF on Windows. See mail_line_endings in settings.php. + preg_replace('@\r?\n@', $line_endings, $message['body']), // For headers, PHP's API suggests that we use CRLF normally, // but some MTAs incorrectly replace LF with CRLF. See #234403. join("\n", $mimeheaders) diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index b8b4dbbe7..e869027b7 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -167,6 +167,15 @@ $db_prefix = ''; $update_free_access = FALSE; /** + * Line endings for e-mail messages + * + * Drupal automatically guesses the line-ending format appropriate for your + * system. If you need to override this, uncomment the statement below and set + * it to the line-ending string of your choice. + */ +# $conf['mail_line_endings'] = "\r\n"; + +/** * Base URL (optional). * * If you are experiencing issues with different site domains, |