version 1.52, 2003/03/31 16:34:08
|
version 1.54, 2003/04/02 14:57:32
|
Line 52 use Apache::Constants qw(:common);
|
Line 52 use Apache::Constants qw(:common);
|
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lontexconvert(); |
use Apache::lontexconvert(); |
use HTML::Entities(); |
use HTML::Entities(); |
|
use Mail::Send; |
|
|
# ===================================================================== Package |
# ===================================================================== Package |
|
|
Line 142 sub unpackmsgid {
|
Line 143 sub unpackmsgid {
|
return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid}); |
return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid}); |
} |
} |
|
|
|
|
|
sub sendemail { |
|
my ($to,$subject,$body)=@_; |
|
$body= |
|
"*** This is an automatic message generated by the LON-CAPA system.\n". |
|
"*** Please do not reply to this address.\n\n".$body; |
|
my $msg = new Mail::Send; |
|
$msg->to($to); |
|
$msg->subject('[LON-CAPA] '.$subject); |
|
my $fh = $msg->open('smtp',Server => 'localhost'); |
|
print $fh $body; |
|
$fh->close; |
|
} |
|
|
|
# ==================================================== Send notification emails |
|
|
|
sub sendnotification { |
|
my ($to,$touname,$toudom,$subj,$crit)=@_; |
|
my $sender=$ENV{'environment.firstname'}.' '.$ENV{'environment.lastname'}; |
|
my $critical=($crit?' critical':''); |
|
my $url='http://'. |
|
$Apache::lonnet::hostname{&Apache::lonnet::homeserver($touname,$toudom)}. |
|
'/adm/email?username='.$touname.'&domain='.$toudom; |
|
my $body=(<<ENDMSG); |
|
You received a$critical message from $sender in LON-CAPA. The subject is |
|
|
|
$subj |
|
|
|
Use |
|
|
|
$url |
|
|
|
to access this message. |
|
ENDMSG |
|
&sendemail($to,'New'.$critical.' message from '.$sender,$body); |
|
} |
# ============================================================= Check for email |
# ============================================================= Check for email |
|
|
sub newmail { |
sub newmail { |
Line 199 sub user_crit_msg_raw {
|
Line 236 sub user_crit_msg_raw {
|
} else { |
} else { |
$status='no_host'; |
$status='no_host'; |
} |
} |
|
# Notifications |
|
my %userenv = &Apache::lonnet::get('environment',['critnotification'], |
|
$domain,$user); |
|
if ($userenv{'critnotification'}) { |
|
&sendnotification($userenv{'critnotification'},$user,$domain,$subject,1); |
|
} |
|
# Log this |
&Apache::lonnet::logthis( |
&Apache::lonnet::logthis( |
'Sending critical email '.$msgid. |
'Sending critical email '.$msgid. |
', log status: '. |
', log status: '. |
Line 277 sub user_normal_msg_raw {
|
Line 321 sub user_normal_msg_raw {
|
} else { |
} else { |
$status='no_host'; |
$status='no_host'; |
} |
} |
|
# Notifications |
|
my %userenv = &Apache::lonnet::get('environment',['notification'], |
|
$domain,$user); |
|
if ($userenv{'notification'}) { |
|
&sendnotification($userenv{'notification'},$user,$domain,$subject,0); |
|
} |
&Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'}, |
&Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'}, |
$ENV{'user.home'}, |
$ENV{'user.home'}, |
'Sending '.$msgid.' to '.$user.' at '.$domain.' with status: '.$status); |
'Sending '.$msgid.' to '.$user.' at '.$domain.' with status: '.$status); |