Index: includes/common.inc
===================================================================
--- includes/common.inc	(revision 6636)
+++ includes/common.inc	(working copy)
@@ -1917,14 +1917,19 @@ function page_set_cache() {
  *   FALSE otherwise.
  */
 function drupal_mail($mailkey, $to, $subject, $body, $from = NULL, $headers = array()) {
-  $defaults = array(
+  $defaults = array();
+  // RFC 821 Sec 4.1.1 says Return-Path goes first. See RFC 2822 Sec 3.6.2 regarding Sender.
+  if (variable_get('site_mail', ini_get('sendmail_from'))) {
+    $defaults['Errors-To'] = $defaults['Sender'] = $defaults['Return-Path'] = variable_get('site_mail', ini_get('sendmail_from'));
+  }
+  $defaults += array(
     'MIME-Version' => '1.0',
     'Content-Type' => 'text/plain; charset=UTF-8; format=flowed',
     'Content-Transfer-Encoding' => '8Bit',
     'X-Mailer' => 'Drupal'
   );
   if (isset($from)) {
-    $defaults['From'] = $defaults['Reply-To'] = $defaults['Return-Path'] = $defaults['Errors-To'] = $from;
+    $defaults['From'] = $defaults['Reply-To'] = $from;
   }
   $headers = array_merge($defaults, $headers);
   // Custom hook traversal to allow pass by reference
