diff --git a/smtp.mail.inc b/smtp.mail.inc
index 94b140b..e5b1ddd 100644
--- a/smtp.mail.inc
+++ b/smtp.mail.inc
@@ -87,10 +87,16 @@ class SmtpMailSystem implements MailSystemInterface {
     }
 
     //Hack to fix reply-to issue.
-    $properfrom = variable_get('site_mail', '');
+    $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", ['!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 +107,31 @@ class SmtpMailSystem implements MailSystemInterface {
       $headers['Reply-To'] = $reply;
     }
 
-    // Blank value will let the e-mail address appear.
+    // Use sender to prevent 'You are not allowed to send mail from domain $from'
+    if (($sender = variable_get('smtp_from', '')) == '') {
+      // If 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 ($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;
-        }
+      $from = $sender;
+    }
+
+    if ($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 ($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 +149,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.
