--- loncom/interface/lonmsg.pm 2023/01/23 17:52:06 1.239.2.4.2.1 +++ 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.2.1 2023/01/23 17:52:06 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; + } } } } @@ -512,8 +520,10 @@ sub sendnotification { $text=~s/\<\;/\/gs; - my $touhome = &Apache::lonnet::homeserver($touname,$toudom); - my $url = &Apache::lonnet::url_prefix('',$toudom,$touhome,'email'). + my $homeserver = &Apache::lonnet::homeserver($touname,$toudom); + my $protocol = $Apache::lonnet::protocol{$homeserver}; + $protocol = 'http' if ($protocol ne 'https'); + my $url = $protocol.'://'.&Apache::lonnet::hostname($homeserver). '/adm/email?username='.$touname.'&domain='.$toudom. '&display='.&escape($msgid); my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid,