--- loncom/interface/lonmsg.pm 2022/01/19 03:33:46 1.239.2.4 +++ loncom/interface/lonmsg.pm 2024/02/08 03:09:10 1.239.2.5 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.239.2.4 2022/01/19 03:33:46 raeburn Exp $ +# $Id: lonmsg.pm,v 1.239.2.5 2024/02/08 03:09:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -455,14 +455,17 @@ sub sendemail { $replytoaddress = 'do-not-reply@'.$hostname; } else { my %senderemails; - my $have_sender; + my ($have_sender,$setreplyto); if ($env{'form.reply_to_addr'}) { my ($replytoname,$replytodom) = split(/:/,$env{'form.reply_to_addr'}); - if (!($replytoname eq $env{'user.name'} && $replytodom eq $env{'user.domain'})) { + if (($replytoname eq $env{'user.name'} && $replytodom eq $env{'user.domain'})) { + $setreplyto = 1; + } else { if (&Apache::lonnet::homeserver($replytoname,$replytodom) ne 'no_host') { %senderemails = &Apache::loncommon::getemails($replytoname,$replytodom); $have_sender = 1; + $setreplyto = 1; } } } @@ -472,7 +475,12 @@ sub sendemail { foreach my $type ('permanentemail','critnotification','notification') { if ($senderemails{$type}) { ($senderaddress) = split(/,/,$senderemails{$type}); - last if ($senderaddress); + if ($senderaddress) { + if ($setreplyto) { + $replytoaddress = $senderaddress; + } + last; + } } } }