[rt-devel] Make the "From:" line show the sender's address instead of the queue's address.

Dan Wright wright at smx.pair.com
Mon Nov 10 16:00:53 EST 2003


  For our RT installation, we decided that when RT sends out copies of
correspondences to ticket Requesters and Cc's, that we'd rather have the email
address of the Requester be listed in the "From:" field of the email, than the
address of the queue.  We use the "Reply-To:" field to list the address of the
requester.

  Perhaps this could be a configurable option in a future release of RT?

  Here is the source code that shows our modifications in case anybody is
interested:



package RT::Action::SendEmail_Local;

sub SetReturnAddress {

    my $self = shift;
    my %args = ( is_comment => 0,
                 @_ );

    # From and Reply-To
    # $args{is_comment} should be set if the comment address is to be used.
    my $replyto;

    if ( $args{'is_comment'} ) {
        $replyto = $self->TicketObj->QueueObj->CommentAddress
          || $RT::CommentAddress;
    }
    else {
        $replyto = $self->TicketObj->QueueObj->CorrespondAddress
          || $RT::CorrespondAddress;
    }

    unless ( $self->TemplateObj->MIMEObj->head->get('From') ) {
        if ($RT::UseFriendlyFromLine) {
            my $friendly_name = $self->TransactionObj->CreatorObj->RealName;
            if ( $friendly_name =~ /^"(.*)"$/ ) {    # a quoted string
                $friendly_name = $1;
            }

        my $sender_address =  $self->TransactionObj->CreatorObj->EmailAddress;

            $friendly_name =~ s/"/\\"/g;
            $self->SetHeader( 'From',
                        sprintf($RT::FriendlyFromLineFormat,
                $self->MIMEEncodeString( $friendly_name,
$RT::EmailOutputEncoding ), $sender_address),
            );
        }
        else {
            $self->SetHeader( 'From', $replyto );
        }
    }

    unless ( $self->TemplateObj->MIMEObj->head->get('Reply-To') ) {
        $self->SetHeader( 'Reply-To', "$replyto" );
    }

}




More information about the Rt-devel mailing list