Index: includes/mail.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/mail.inc,v
retrieving revision 1.30
diff -u -p -r1.30 mail.inc
--- includes/mail.inc	9 Jan 2010 23:03:21 -0000	1.30
+++ includes/mail.inc	14 Jan 2010 21:49:09 -0000
@@ -118,10 +118,10 @@ function drupal_mail($module, $key, $to,
     'X-Mailer'                  => 'Drupal'
   );
   if ($default_from) {
-    // To prevent e-mail from looking like spam, the addresses in the Sender and
-    // Return-Path headers should have a domain authorized to use the originating
-    // SMTP server. Errors-To is redundant, but shouldn't hurt.
-    $headers['From'] = $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $default_from;
+    // To prevent e-mail from looking like spam, 'Sender' and 'Return-Path'
+    // should be addresses of a domain authorized to use the originating
+    // SMTP server. 'Errors-To' is redundant, but shouldn't hurt.
+    $headers['From'] = $headers['Sender'] = $headers['Errors-To'] = $headers['Return-Path'] = $default_from;
   }
   if ($from) {
     $headers['From'] = $from;
@@ -141,6 +141,7 @@ function drupal_mail($module, $key, $to,
   // Retrieve the responsible implementation for this message.
   $system = drupal_mail_system($module, $key);
 
+
   // Format the message body.
   $message = $system->format($message);
 
Index: modules/system/system.mail.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.mail.inc,v
retrieving revision 1.1
diff -u -p -r1.1 system.mail.inc
--- modules/system/system.mail.inc	15 Dec 2009 08:37:18 -0000	1.1
+++ modules/system/system.mail.inc	14 Jan 2010 21:49:10 -0000
@@ -41,6 +41,20 @@ class DefaultMailSystem implements MailS
    *   TRUE if the mail was successfully accepted, otherwise FALSE.
    */
   public function mail(array $message) {
+    // If 'Return-Path' isn't already set in php.ini, we pass it separately
+    // as an additional parameter instead of in the header.
+    // However, if PHP's 'safe_mode' is on, this is not allowed.
+    if (isset($message['headers']['Return-Path'])) {
+      $return_path_set = strpos(ini_get('sendmail_path'), ' -f');
+      if (!$return_path_set) {
+        $message['Return-Path'] = $message['headers']['Return-Path'];
+        unset($message['headers']['Return-Path']);
+      }
+    } 
+  
+  
+  
+  
     $mimeheaders = array();
     foreach ($message['headers'] as $name => $value) {
       $mimeheaders[] = $name . ': ' . mime_header_encode($value);
@@ -56,7 +70,9 @@ class DefaultMailSystem implements MailS
       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)
+      join("\n", $mimeheaders),
+      // Pass the Return-Path via sendmail's -f command.
+      $message['Return-Path'] ? '-f ' . $message['Return-Path'] : ''
     );
   }
 }
