#!/usr/local/bin/perl # Send the usermin feedback form require './web-lib.pl'; &init_config(); require './ui-lib.pl'; &switch_to_remote_user(); &create_user_config_dirs(); &ReadParseMime(); &error_setup($text{'feedback_err'}); $gconfig{'feedback'} || &error($text{'feedback_ecannot'}); # Construct the email body $in{'text'} =~ s/\r//g; $date = localtime(time()); $ver = &get_webmin_version(); if ($in{'name'} && $in{'email'}) { $from = "$in{'name'} <$in{'email'}>"; $email = $in{'email'}; } elsif ($in{'email'}) { $email = $from = $in{'email'}; } else { $email = $from = "feedback\@".&get_system_hostname(); } local $m = $in{'module'}; $m || !$in{'config'} || &error($text{'feedback_emodule'}); &check_os_support($m) && $m !~ /\.\./ || &error($text{'feedback_emodule2'}); if ($m) { %minfo = &get_module_info($m); $ver .= " (Module: $minfo{'version'})" if ($minfo{'version'}); $module = "$m ($minfo{'desc'})"; } else { $module = "None"; } @tolist = ( $gconfig{'feedback'} ); foreach $t (@tolist) { $headers .= "To: $t\n"; } $headers .= "From: $from\n"; $headers .= "Subject: $text{'feedback_title'}\n"; $attach[0] = <$gconfig{'feedbackmail'}"),"\n"; } elsif ($sent == 2) { print &text('feedback_prog', join(",", @tolist), "$sendmail"),"\n"; } else { print &text('feedback_via', join(",", @tolist), "localhost"),"\n"; } print "

\n"; &ui_print_footer("/", $text{'index'}); } else { # Give up! Tell the user .. &error($text{'feedback_esend'}); } sub send_via_smtp { local $error; &open_socket($_[0], 25, MAIL, \$error); return 0 if ($error); &smtp_command(MAIL) || return 0; &smtp_command(MAIL, "helo ".&get_system_hostname()."\r\n") || return 0; &smtp_command(MAIL, "mail from: $email\r\n") || return 0; foreach $t (@tolist) { &smtp_command(MAIL, "rcpt to: $t\r\n") || return 0; } &smtp_command(MAIL, "data\r\n"); $mail =~ s/\r//g; $mail =~ s/\n/\r\n/g; print MAIL $mail; &smtp_command(MAIL, ".\r\n"); &smtp_command(MAIL, "quit\r\n"); close(MAIL); return 1; } # smtp_command(handle, command) sub smtp_command { local ($m, $c) = @_; print $m $c; local $r = <$m>; return $r =~ /^[23]\d+/; } sub short_name { $_[0] =~ /([^\\\/]+)$/; return $1; }