diff --git a/modules/contact/contact.test b/modules/contact/contact.test
index 6a1674a0df..75cf7636a5 100644
--- a/modules/contact/contact.test
+++ b/modules/contact/contact.test
@@ -323,6 +323,32 @@ class ContactPersonalTestCase extends DrupalWebTestCase {
     $this->contact_user = $this->drupalCreateUser();
   }
 
+  /**
+   * Tests that mails for contact messages are correctly sent.
+   */
+  public function testSendPersonalContactMessage() {
+    // Replace the web user's email so we can check the headers.
+    $reply_email = $edit['mail'] = $this->web_user->name . '&escaped@example.net';
+    $from_email = variable_get('site_mail', 'simpletest@example.com');
+    $account = user_load($this->web_user->uid);
+    user_save($account, $edit);
+
+    $this->drupalLogin($this->web_user);
+    $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
+    $this->assertRaw(check_plain($reply_email));
+    $this->submitPersonalContact($this->contact_user);
+
+    // Assume the most recent email.
+    $captured_emails = $this->drupalGetMails();
+    $email = end($captured_emails);
+
+    $this->assertEqual(1, count($captured_emails));
+    $this->assertEqual($email['to'], $this->contact_user->mail);
+    $this->assertEqual($email['from'], "\"$reply_email via Drupal\" <$from_email>");
+    $this->assertEqual($email['headers']['Reply-To'], $reply_email);
+    $this->assertEqual($email['key'], 'user_mail');
+  }
+
   /**
    * Tests access to the personal contact form.
    */
diff --git a/modules/simpletest/tests/mail.test b/modules/simpletest/tests/mail.test
index 3e40e13a89..168cfb50bb 100644
--- a/modules/simpletest/tests/mail.test
+++ b/modules/simpletest/tests/mail.test
@@ -59,6 +59,34 @@ class MailTestCase extends DrupalWebTestCase implements MailSystemInterface {
     $this->assertNull(self::$sent_message, 'Message was canceled.');
   }
 
+  /**
+   * Checks the From: and Reply-to: headers.
+   */
+  function testFromAndReplyToHeader() {
+    global $language;
+
+    $reply_email = 'foo&escaped@example.net';
+    $from_email = variable_get('site_mail', 'simpletest@example.com');
+
+    // Reset the class variable holding a copy of the last sent message.
+    self::$sent_message = NULL;
+    // Use MailTestCase for sending a message.
+    drupal_mail('simpletest', 'from_test', 'from_test@example.com', $language, array(), $reply_email);
+    // Test that the reply-to e-mail is just the e-mail and not the site name and
+    // default sender e-mail.
+    $this->assertEqual("\"$reply_email via Drupal\" <$from_email>", self::$sent_message['headers']['From'], 'Message is sent from the site email account.');
+    $this->assertEqual($reply_email, self::$sent_message['headers']['Reply-To'], 'Message reply-to headers are set.');
+    $this->assertFalse(isset(self::$sent_message['headers']['Errors-To']), 'Errors-to header must not be set, it is deprecated.');
+
+    // Reset the class variable holding a copy of the last sent message.
+    self::$sent_message = NULL;
+    // Send an e-mail and check that the From-header contains the site name.
+    drupal_mail('simpletest', 'from_test', 'from_test@example.com', $language);
+    $this->assertEqual($from_email, self::$sent_message['headers']['From'], 'Message is sent from the site email account.');
+    $this->assertFalse(isset(self::$sent_message['headers']['Reply-to']), 'Message reply-to is not set if not specified.');
+    $this->assertFalse(isset(self::$sent_message['headers']['Errors-To']), 'Errors-to header must not be set, it is deprecated.');
+  }
+
   /**
    * Concatenate and wrap the e-mail body for plain-text mails.
    *
