--- loncom/interface/lonmsg.pm 2015/06/18 21:42:37 1.240 +++ loncom/interface/lonmsg.pm 2015/06/23 02:42:34 1.242 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.240 2015/06/18 21:42:37 musolffc Exp $ +# $Id: lonmsg.pm,v 1.242 2015/06/23 02:42:34 musolffc Exp $ # # Copyright Michigan State University Board of Trustees # @@ -200,9 +200,9 @@ Returns use strict; use Apache::lonnet; +use Apache::loncommon; use HTML::TokeParser(); use Apache::lonlocal; -use MIME::Entity; use HTML::Entities; use Encode; use LONCAPA qw(:DEFAULT :match); @@ -460,20 +460,15 @@ sub sendemail { $attachmenturl = &Apache::lonnet::filelocation("",$attachmenturl); my $filesize = (stat($attachmenturl))[7]; if ($filesize > 1048576) { + # Don't send if it exceeds 1 MB. print '

' .&mt('Email not sent. Attachment exceeds permitted length.') .'

'; } else { - my $top = MIME::Entity->build( Type => "multipart/mixed", - From => $senderaddress, - To => $to, - Subject => '[LON-CAPA] '.$subject); - $top->attach(Data=>$body); - $top->attach(Path=>$attachmenturl); - - open MAIL, "| /usr/lib/sendmail -t -oi -oem" or die "open: $!"; - $top->print(\*MAIL); - close MAIL; + # Otherwise build and send the email + $subject = '[LON-CAPA] '.$subject; + &Apache::loncommon::mime_email($senderaddress, $to, $subject, $body, ,'', + '', $attachmenturl, '', ''); $msgsent = 1; } return $msgsent;