diff --git a/smtp.mail.inc b/smtp.mail.inc
index e35faa8..26db084 100644
--- a/smtp.mail.inc
+++ b/smtp.mail.inc
@@ -84,8 +84,18 @@ class SmtpMailSystem implements MailSystemInterface {
       // If value is not defined in settings, use site_name.
       $from_name = variable_get('site_name', '');
     }
+    $smpt_from_var = variable_get('smpt_from', FALSE);
 
     //Hack to fix reply-to issue.
+    $properfrom = $smtp_from_var ? $smtp_from_var : variable_get('site_mail', '');
+    if (!empty($properfrom)) {
+      $headers['From'] = $properfrom;
+    }
+
+    if ($smtp_from_var) {
+      $from_name = t("!name via !site_name", array('!name' => $from_name, '!site_name' => variable_get('site_name', '')));
+    }
+
     if (!isset($headers['Reply-To']) || empty($headers['Reply-To'])) {
       if (strpos($from, '<')) {
         $reply = preg_replace('/>.*/', '', preg_replace('/.*</', '', $from));
@@ -95,27 +105,35 @@ class SmtpMailSystem implements MailSystemInterface {
       }
       $headers['Reply-To'] = $reply;
     }
-    $properfrom = variable_get('site_mail', '');
-    if (!empty($properfrom)) {
-      $headers['From'] = $properfrom;
-      $from = $properfrom;
+
+    // Use sender to prevent 'You are not allowed to send mail from domain
+    // $from'.
+    $sender = $smtp_from_var;
+
+    if (empty($sender)) {
+      // If the 'smtp_from' config option is blank, use 'site_email'.
+      $sender = variable_get('site_mail', '');
     }
 
     // Blank value will let the e-mail address appear.
-
-    if ($from == NULL || $from == '') {
-      // If from e-mail address is blank, use smtp_from config option.
-      if (($from = variable_get('smtp_from', '')) == '') {
-        // If smtp_from config option is blank, use site_email.
-        if (($from = variable_get('site_mail', '')) == '') {
-          drupal_set_message(t('There is no submitted from address.'), 'error');
-          if ($logging) {
-            watchdog('smtp', 'There is no submitted from address.', array(), WATCHDOG_ERROR);
-          }
-          return FALSE;
-        }
+    // If from e-mail address is blank, use smtp_from config option.
+    if (empty($from)) {
+      $from = $sender;
+    }
+    // If the 'from' address is still empty, fail.
+    if (emtpy($from)) {
+      drupal_set_message(t('There is no submitted from address.'), 'error');
+      if ($logging) {
+        watchdog('smtp', 'There is no submitted from address.', array(), WATCHDOG_ERROR);
       }
+      return FALSE;      
     }
+
+    if (empty($sender)) {
+      // Will work only for servers that do not check for phishing.
+      $sender = $from;
+    }
+
     if (preg_match('/^"?.*"?\s*<.*>$/', $from)) {
       // . == Matches any single character except line break characters \r and \n.
       // * == Repeats the previous item zero or more times.
@@ -133,7 +151,7 @@ class SmtpMailSystem implements MailSystemInterface {
     // Defines the From value to what we expect.
     $mailer->From     = $from;
     $mailer->FromName = $from_name;
-    $mailer->Sender   = $from;
+    $mailer->Sender   = $sender;
 
 
     // Create the list of 'To:' recipients.
@@ -151,6 +169,7 @@ class SmtpMailSystem implements MailSystemInterface {
       $mailer->AddAddress($toaddr, $toname);
     }
 
+    $replytoAdded = false;
 
     // Parse the headers of the message and set the PHPMailer object's settings
     // accordingly.
@@ -239,10 +258,12 @@ class SmtpMailSystem implements MailSystemInterface {
               $replyToName = trim($replyToName, '"');
               $replyToAddr = rtrim($replyToParts[1], '>');
               $mailer->AddReplyTo($replyToAddr, $replyToName);
+              $mailer->FromName = t("!name via !site_name", array('!name' => $replyToName, '!site_name' => variable_get('site_name', '')));
             }
             else {
               $mailer->AddReplyTo($value);
             }
+            $replytoAdded = true;
           }
           break;
 
@@ -311,6 +332,10 @@ class SmtpMailSystem implements MailSystemInterface {
           $mailer->AddCustomHeader($key . ': ' . $value);
       }
     }
+    // Add the reply to
+    if (!$replytoAdded && $smtp_from_var) {
+      $mailer->AddReplyTo($properfrom, $from_name);
+    }
 
     /**
      * TODO
