RT 3.8.17
[freeside.git] / rt / lib / RT / Action / SendEmail.pm
index 189b999..8aaa871 100755 (executable)
@@ -2,7 +2,7 @@
 #
 # COPYRIGHT:
 #
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
 #                                          <sales@bestpractical.com>
 #
 # (Except where explicitly superseded by other copyright notices)
@@ -851,6 +851,9 @@ sub SetReturnAddress {
     }
 
     unless ( $self->TemplateObj->MIMEObj->head->get('From') ) {
+
+        my $from = $replyto;
+
         if ( RT->Config->Get('UseFriendlyFromLine') ) {
             my $friendly_name = $args{friendly_name};
 
@@ -862,19 +865,22 @@ sub SetReturnAddress {
             }
 
             $friendly_name =~ s/"/\\"/g;
-            $self->SetHeader(
-                'From',
+            $from =
                 sprintf(
                     RT->Config->Get('FriendlyFromLineFormat'),
                     $self->MIMEEncodeString(
                         $friendly_name, RT->Config->Get('EmailOutputEncoding')
                     ),
                     $replyto
-                ),
-            );
-        } else {
-            $self->SetHeader( 'From', $replyto );
+                );
         }
+
+        $self->SetHeader( 'From', $from );
+
+        #also set Sender:, otherwise MTAs add a nonsensical value like
+        # rt@machine, and then Outlook prepends "rt@machine on behalf of" to
+        # the From: header
+        $self->SetHeader( 'Sender', $from );
     }
 
     unless ( $self->TemplateObj->MIMEObj->head->get('Reply-To') ) {