--- loncom/interface/lonsupportreq.pm 2017/01/23 01:56:26 1.79.2.2 +++ loncom/interface/lonsupportreq.pm 2017/01/18 21:07:31 1.85 @@ -1,5 +1,5 @@ # -# $Id: lonsupportreq.pm,v 1.79.2.2 2017/01/23 01:56:26 raeburn Exp $ +# $Id: lonsupportreq.pm,v 1.85 2017/01/18 21:07:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,8 +27,6 @@ package Apache::lonsupportreq; use strict; -use MIME::Types; -use MIME::Lite; use CGI::Cookie(); use Apache::Constants qw(:common); use Apache::loncommon(); @@ -79,7 +77,7 @@ sub handler { } return OK; } - + sub print_request_form { my ($r,$origurl,$function) = @_; my ($os,$browser,$bversion,$uname,$udom,$uhome,$urole,$usec,$email,$cid, @@ -105,7 +103,7 @@ sub print_request_form { } } } - if (($env{'user.name'} =~ /^$match_username$/) && + if (($env{'user.name'} =~ /^$match_username$/) && ($env{'user.domain'} =~ /^$match_domain$/) && (!$public)) { $knownuser = 1; } else { @@ -153,7 +151,7 @@ sub print_request_form { subj => 'Subject', detd => 'Detailed Description', opfi => 'Optional file upload', - uplf => 'Upload a file (e.g., a screenshot) relevant to your help request (128 KB max.)', + uplf => 'Upload a file (e.g., a screenshot) relevant to your help request (1 MB max.)', fini => 'Finish', clfm => 'Clear Form', ); @@ -283,6 +281,7 @@ $jscript $loaditems // ]]> + ENDJS if ($recaptcha_version >=2) { $js.= "\n".''."\n"; @@ -341,7 +340,7 @@ ENDJS $num ++; $i = $num%2; if ($knownuser) { - if ($homeserver) { + if ($homeserver) { $output .= &Apache::lonhtmlcommon::row_title($html_lt{'emac'},undef,$css[$i]). '
'."\n". &Apache::lonhtmlcommon::row_closure(); @@ -516,10 +515,11 @@ ENDJS $i = $num%2; if ($knownuser) { if ($homeserver) { - $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i]). - '
'. - "\n".$html_lt{'uplf'}."\n". - &Apache::lonhtmlcommon::row_closure(); + $output .= &Apache::lonhtmlcommon::row_title($html_lt{'opfi'},undef,$css[$i]) + .' ' + .'' + .'
'."\n".$html_lt{'uplf'}."\n" + .&Apache::lonhtmlcommon::row_closure(); $num ++; $i = $num%2; } @@ -850,9 +850,9 @@ END if ((defined($env{'user.name'})) && (!$public)) { if ($homeserver && $env{'form.screenshot.filename'}) { $attachmentsize = length($env{'form.screenshot'}); - if ($attachmentsize > 131072) { + if ($attachmentsize > 1048576) { $displaymsg .= '
'. - &mt('The uploaded screenshot file ([_1] bytes) included with your request exceeded the maximum allowed size - 128 KB, and has therefore been discarded.',$attachmentsize).''; + &mt('The uploaded screenshot file ([_1] bytes) included with your request exceeded the maximum allowed size - 1 MB, and has therefore been discarded.',$attachmentsize).''; } else { $attachmentpath=&Apache::lonnet::userfileupload('screenshot',undef,'helprequests'); } @@ -885,33 +885,15 @@ END } } - my $msg = MIME::Lite->new( - From => $from, - To => $to, - Subject => $subject, - Type =>'TEXT', - Data => $supportmsg, - ); + my $cc_string; if ($homeserver) { if (@ok_ccs > 0) { - my $cc_string = join(', ',@ok_ccs); - $msg->add("Cc" => $cc_string); + $cc_string = join(', ',@ok_ccs); } } - if ($bcc ne '') { - $msg->add("Bcc" => $bcc); - } - $msg->attr("content-type" => "text/plain"); - $msg->attr("content-type.charset" => "UTF-8"); - - if ($homeserver && $attachmentpath) { - my ($type, $encoding) = MIME::Types::by_suffix($attachmentpath); - $msg->attach(Type => $type, - Path => $attachmentpath, - Filename => $fname - ); - } else { + my $attachment_text; + unless ($homeserver && $attachmentpath) { my $envdata = ''; foreach my $var (@cookievars) { $envdata .= "$var: $cookies{$var}\n"; @@ -925,12 +907,12 @@ END foreach my $var (@loncvars) { $envdata .= "$var: $env{$var}\n"; } - $msg->attach(Type => 'TEXT', - Data => $envdata); + $attachment_text = $envdata; } - -### Send it: - $msg->send('sendmail'); + + # Compose and send a MIME email + &Apache::loncommon::mime_email($from, $to, $subject, $supportmsg, $cc_string, $bcc, + $attachmentpath, $fname, $attachment_text); if ($attachmentpath =~ m|$Apache::lonnet::perlvar{'lonDaemons'}/tmp/helprequests/(\d+)/[^/]+|) { unlink($attachmentpath);