diff --git a/smtp.mail.inc b/smtp.mail.inc
index f235094..7a1e003 100644
--- a/smtp.mail.inc
+++ b/smtp.mail.inc
@@ -86,6 +86,16 @@ class SmtpMailSystem implements MailSystemInterface {
     }
 
     //Hack to fix reply-to issue.
+    $properfrom = variable_get('smtp_from', FALSE) ? variable_get('smtp_from') : variable_get('site_mail', '');
+    if (!empty($properfrom)) {
+      $headers['From'] = $properfrom;
+    }
+
+    if (variable_get('smtp_from', FALSE)) {
+      $mailer->AddReplyTo($properfrom, $from_name);
+      $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));
@@ -101,21 +111,34 @@ class SmtpMailSystem implements MailSystemInterface {
       $from = $properfrom;
     }
 
+    // Use sender to prevent 'You are not allowed to send mail from domain
+    // $from'.
+    $sender = variable_get('smtp_from', '');
+    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 e-mail address is blank, use smtp_from config option.
+    if (empty($from)) {
+      $from = $sender;
+    }
 
-    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 the 'from' address is still empty, fail.
+    if (empty($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 +156,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.
