diff --git a/includes/mail.inc b/includes/mail.inc
index 0e5c178..d3472fe 100644
--- a/includes/mail.inc
+++ b/includes/mail.inc
@@ -121,6 +121,7 @@ define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || (isset($_SERVER['SERVER
  */
 function drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE) {
   $default_from = variable_get('site_mail', ini_get('sendmail_from'));
+  $from = isset($from) ? $from : $default_from;
 
   // Bundle up the variables into a structured array for altering.
   $message = array(
@@ -128,7 +129,7 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
     'module'   => $module,
     'key'      => $key,
     'to'       => $to,
-    'from'     => isset($from) ? $from : $default_from,
+    'from'     => $from,
     'language' => $language,
     'params'   => $params,
     'send'     => TRUE,
@@ -154,6 +155,33 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
   }
   $message['headers'] = $headers;
 
+  // If requested set Reply-To to the From and re-format From address.
+  if (variable_get('site_mail_replyto') &&
+      empty($message['headers']['Reply-To']) &&
+      ($default_from_name = variable_get('site_name', 'Drupal')) &&
+      ($default_from_parts = explode('@', $default_from)) &&
+      count($default_from_parts) == 2 &&
+      $default_from_parts[1] &&
+      stripos($message['from'], '@' . $default_from_parts[1]) === FALSE) {
+    // Message is not already being sent from the domain of the default from address.
+    $message['headers']['From'] = $default_from;
+    $message['headers']['Reply-To'] = $message['from'];
+    // Match e-mails of the form 'My Name <email@domain.com>' as follows:
+    // ^          = beginning of string
+    // "?         = optional quote
+    // ([^<]*?)   = match optional characters that aren't a < (non-greedy)
+    // "?         = optional quote
+    // SPACE*     = optional spaces
+    // (?:<(.*)>) = < matching stuff > (without the angle brakets)
+    // $          = end of string
+    preg_match('/^"?([^<]*?)"? *(?:<(.*)>)?$/', $message['from'], $matches);
+    $message['from'] = $matches ? t('"!name via !site_name" <!site_mail>',
+                         array('!name' => empty($matches[1]) ? $matches[2] : $matches[1],
+                                '!site_name' => $default_from_name,
+                                '!site_mail' => $default_from))
+                       : $default_from;
+  }
+
   // Build the e-mail (get subject and body, allow additional headers) by
   // invoking hook_mail() on this module. We cannot use module_invoke() as
   // we need to have $message by reference in hook_mail().
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index 16c40d4..89c00cd 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -1519,6 +1519,12 @@ function system_site_information_settings() {
     '#description' => t("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"),
     '#required' => TRUE,
   );
+  $form['site_information']['site_mail_replyto'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use Reply-To header'),
+    '#default_value' => variable_get('site_mail_replyto', TRUE),
+    '#description' => t('Sends all e-mail from the domain of the default address above and sets the "Reply-To" header to the actual sender. Helps prevent e-mail from being flagged as spam.'),
+  );
   $form['front_page'] = array(
     '#type' => 'fieldset',
     '#title' => t('Front page'),
