Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.284
diff -u -r1.284 bootstrap.inc
--- includes/bootstrap.inc	26 May 2009 09:12:28 -0000	1.284
+++ includes/bootstrap.inc	1 Jun 2009 05:51:50 -0000
@@ -455,7 +455,7 @@
   global $base_url, $base_path, $base_root;
 
   // Export the following settings.php variables to the global namespace
-  global $databases, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url;
+  global $databases, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $mail_line_endings;
   $conf = array();
 
   if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.php')) {
Index: includes/mail.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/mail.inc,v
retrieving revision 1.20
diff -u -r1.20 mail.inc
--- includes/mail.inc	7 May 2009 10:41:12 -0000	1.20
+++ includes/mail.inc	1 Jun 2009 05:51:50 -0000
@@ -181,12 +181,16 @@
     foreach ($message['headers'] as $name => $value) {
       $mimeheaders[] = $name . ': ' . mime_header_encode($value);
     }
+    global $mail_line_endings;
+    if (!isset($mail_line_endings)) {
+      $mail_line_endings = "\n";
+    }
     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@', $mail_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)
Index: sites/default/default.settings.php
===================================================================
RCS file: /cvs/drupal/drupal/sites/default/default.settings.php,v
retrieving revision 1.24
diff -u -r1.24 default.settings.php
--- sites/default/default.settings.php	24 Apr 2009 08:16:56 -0000	1.24
+++ sites/default/default.settings.php	1 Jun 2009 05:51:50 -0000
@@ -165,6 +165,23 @@
 $update_free_access = FALSE;
 
 /**
+ * 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 it 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.
+ */
+$mail_line_endings = "\n";
+if (isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE) {
+  $mail_line_endings = "\r\n";
+}
+
+/**
  * Base URL (optional).
  *
  * If you are experiencing issues with different site domains,
