--- loncom/interface/lonmsg.pm 2006/06/12 22:55:23 1.185 +++ loncom/interface/lonmsg.pm 2006/12/06 17:14:50 1.188 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.185 2006/06/12 22:55:23 albertel Exp $ +# $Id: lonmsg.pm,v 1.188 2006/12/06 17:14:50 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,8 +33,7 @@ use Apache::lonnet; use HTML::TokeParser(); use Apache::lonlocal; use Mail::Send; -use lib '/home/httpd/lib/perl/'; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); { my $uniq; @@ -210,12 +209,21 @@ sub unpackmsgid { sub sendemail { my ($to,$subject,$body)=@_; + my %senderemails=&Apache::loncommon::getemails(); + my $senderaddress=''; + foreach my $type ('notification','permanentemail','critnotification') { + if ($senderemails{$type}) { + $senderaddress=$senderemails{$type}; + } + } $body= "*** ".&mt('This is an automatic message generated by the LON-CAPA system.')."\n". - "*** ".&mt('Please do not reply to this address.')."\n\n".$body; + "*** ".($senderaddress?&mt('You can reply to this message'):&mt('Please do not reply to this address.')."\n*** ". + &mt('A reply will not be received by the recipient!'))."\n\n".$body; my $msg = new Mail::Send; $msg->to($to); $msg->subject('[LON-CAPA] '.$subject); + if ($senderaddress) { $msg->add('Reply-to',$senderaddress); $msg->add('From',$senderaddress); } if (my $fh = $msg->open()) { print $fh $body; $fh->close; @@ -299,7 +307,7 @@ sub author_res_msg { sub retrieve_author_res_msg { my $url=shift; $url=&Apache::lonnet::declutter($url); - my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//); + my ($domain,$author)=($url=~/^($match_domain)\/($match_username)\//); my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$domain,$author); my $msgs=''; foreach (keys %errormsgs) { @@ -319,7 +327,7 @@ sub retrieve_author_res_msg { sub del_url_author_res_msg { my $url=shift; $url=&Apache::lonnet::declutter($url); - my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//); + my ($domain,$author)=($url=~/^($match_domain)\/($match_username)\//); my @delmsgs=(); foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) { if ($_=~/^\Q$url\E\_\d+$/) { @@ -333,7 +341,7 @@ sub del_url_author_res_msg { sub clear_author_res_msg { my $url=shift; $url=&Apache::lonnet::declutter($url); - my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//); + my ($domain,$author)=($url=~/^($match_domain)\/($match_username)\//); my @delmsgs=(); foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) { if ($_=~/^\Q$url\E/) { @@ -390,9 +398,7 @@ sub user_crit_msg_raw { $status='no_host'; } # Notifications - my %userenv = &Apache::lonnet::get('environment',['critnotification', - 'permanentemail'], - $domain,$user); + my %userenv = &Apache::loncommon::getemails($user,$domain); if ($userenv{'critnotification'}) { &sendnotification($userenv{'critnotification'},$user,$domain,$subject,1, $text);