/usr/share/usermin/mailbox
NameSizeModeActions
images/-0755rm
lang/-0755rm
ulang/-0755rm
address_chooser.cgi52170755editdlrm
add_address.cgi6110755editdlrm
auto.pl19880755editdlrm
boxes-lib.pl835470755editdlrm
CHANGELOG154490644editdlrm
classlinks.sh1600755editdlrm
config-aix4820644editdlrm
config-ALL-linux5030644editdlrm
config-freebsd4780644editdlrm
config-hpux4780644editdlrm
config-irix4770644editdlrm
config-macos4780644editdlrm
config-msc-linux4950644editdlrm
config-netbsd4780644editdlrm
config-openbsd4780644editdlrm
config-openserver4830644editdlrm
config-osf14840644editdlrm
config-qnx4990644editdlrm
config-solaris4770644editdlrm
config-unixware4770644editdlrm
config.info33070644editdlrm
config.info.ca36220755editdlrm
config.info.de16280644editdlrm
config.info.el48740644editdlrm
config.info.hu00644editdlrm
config.info.nl29670755editdlrm
config.info.no31660644editdlrm
copy.cgi8480755editdlrm
copy_form.cgi11610755editdlrm
defaultuconfig7630644editdlrm
delete_folders.cgi13520755editdlrm
delete_mail.cgi71090755editdlrm
detach.cgi31970755editdlrm
detachall.cgi20060755editdlrm
edit_auto.cgi18580755editdlrm
edit_comp.cgi16230755editdlrm
edit_folder.cgi27330755editdlrm
edit_ifolder.cgi10780755editdlrm
edit_imap.cgi19010755editdlrm
edit_pop3.cgi17290755editdlrm
edit_sig.cgi5520755editdlrm
edit_virt.cgi12750755editdlrm
export.cgi13540755editdlrm
folders-lib.pl1352040755editdlrm
import.cgi30970755editdlrm
inbox_login.cgi14470755editdlrm
inbox_login_error.cgi11950755editdlrm
inbox_logout.cgi5030755editdlrm
index.cgi125850755editdlrm
list_addresses.cgi87290755editdlrm
list_folders.cgi53620755editdlrm
list_ifolders.cgi30910755editdlrm
mailbox-lib.pl677380755editdlrm
mail_search.cgi76590755editdlrm
module.info2960644editdlrm
module.info.ar00644editdlrm
module.info.ar.auto2560644editdlrm
module.info.bg00644editdlrm
module.info.bg.auto3050644editdlrm
module.info.ca260644editdlrm
module.info.ca.auto1680644editdlrm
module.info.cs250644editdlrm
module.info.cs.auto1420644editdlrm
module.info.da00644editdlrm
module.info.da.auto1590644editdlrm
module.info.de1190644editdlrm
module.info.el00644editdlrm
module.info.el.auto3570644editdlrm
module.info.es260644editdlrm
module.info.es.auto1630644editdlrm
module.info.eu00644editdlrm
module.info.eu.auto1660644editdlrm
module.info.fa00644editdlrm
module.info.fa.auto2420644editdlrm
module.info.fi00644editdlrm
module.info.fi.auto1490644editdlrm
module.info.fr260644editdlrm
module.info.fr.auto1670644editdlrm
module.info.hr00644editdlrm
module.info.hr.auto1670644editdlrm
module.info.hu380644editdlrm
module.info.hu.auto1730644editdlrm
module.info.it00644editdlrm
module.info.it.auto1510644editdlrm
module.info.ja00644editdlrm
module.info.ja.auto2130644editdlrm
module.info.ko00644editdlrm
module.info.ko.auto1770644editdlrm
module.info.ms00644editdlrm
module.info.ms.auto1370644editdlrm
module.info.nl290644editdlrm
module.info.nl.auto1370644editdlrm
module.info.no190644editdlrm
module.info.no.auto1220644editdlrm
module.info.pl1790644editdlrm
module.info.pl.auto1700644editdlrm
module.info.pt00644editdlrm
module.info.pt.auto1590644editdlrm
module.info.pt_BR00644editdlrm
module.info.pt_BR.auto1650644editdlrm
module.info.ru550644editdlrm
module.info.ru.auto2640644editdlrm
module.info.sk00644editdlrm
module.info.sk.auto1620644editdlrm
module.info.sv00644editdlrm
module.info.sv.auto1500644editdlrm
module.info.tr00644editdlrm
module.info.tr.auto1720644editdlrm
module.info.uk00644editdlrm
module.info.uk.auto2980644editdlrm
module.info.zh00644editdlrm
module.info.zh.auto1410644editdlrm
module.info.zh_TW00644editdlrm
module.info.zh_TW.auto1470644editdlrm
newfolder.cgi2230755editdlrm
print_mail.cgi13580755editdlrm
quotacheck.pl32610755editdlrm
reply_mail.cgi272510755editdlrm
save_address.cgi10340755editdlrm
save_allow.cgi7610755editdlrm
save_auto.cgi11530755editdlrm
save_comp.cgi12660755editdlrm
save_folder.cgi40000755editdlrm
save_group.cgi7970755editdlrm
save_ifolder.cgi18200755editdlrm
save_imap.cgi18990755editdlrm
save_pop3.cgi16670755editdlrm
save_sig.cgi6480755editdlrm
save_virt.cgi10360755editdlrm
search_form.cgi26410755editdlrm
send_mail.cgi194460755editdlrm
slideshow.cgi18230755editdlrm
sort.cgi11630755editdlrm
specialsync.cgi12320755editdlrm
system_info.pl16430644editdlrm
uconfig.info54330644editdlrm
uconfig.info.ca57200755editdlrm
uconfig.info.cs50870644editdlrm
uconfig.info.da00644editdlrm
uconfig.info.de60020644editdlrm
uconfig.info.el74750644editdlrm
uconfig.info.es00644editdlrm
uconfig.info.fr1450644editdlrm
uconfig.info.hu00644editdlrm
uconfig.info.it33480644editdlrm
uconfig.info.nl53370644editdlrm
uconfig.info.no50780644editdlrm
uconfig.info.pl00755editdlrm
uconfig.info.pt_BR50730644editdlrm
uconfig_info.pl3170755editdlrm
view_mail.cgi180860755editdlrm
virtualize.cgi7530755editdlrm
webmin_menu.pl47780644editdlrm
xhr-lib.pl17370644editdlrm
xhr.cgi2520755editdlrm
Edit: /usr/share/usermin/mailbox/reply_mail.cgi (27251B)
#!/usr/bin/perl # Display a form for replying to or composing an email use strict; use warnings; no warnings 'redefine'; no warnings 'uninitialized'; our (%text, %in, %config, %gconfig, %userconfig); our $module_name; our @remote_user_info; our $user_module_config_directory; our $current_theme; require './mailbox-lib.pl'; require '../html-editor-lib.pl'; &ReadParse(); &set_module_index($in{'folder'}); my @folders = &list_folders(); my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders; $folder || &error($text{'view_efolder'}); # XXX Egads, this is hairy! my $html_edit; my $quote; my ($to, $from, $rto, $cc, $bcc, $replyfrom, $sig); my @replyfrom; my @mailforwardids; my @fwdmail; my $mail; my $viewlink; my $mode; my ($subject, $textbody, $htmlbody, $body); my (@attach, @dattach); my $deleted; my $inbox; my $ouser; my $subs; # XXX Very hairy! my @sub; if ($in{'new'}) { # Composing a new email if (defined($in{'html'})) { $html_edit = $in{'html'}; } else { $html_edit = $userconfig{'html_edit'} == 2 ? 1 : 0; } my $sig = &get_signature(); if ($html_edit && $sig) { $sig =~ s/\n/
\n/g; $quote = "$sig"; } else { $quote = "\n\n$sig" if ($sig); } $to = $in{'to'}; if ($userconfig{'charset'}) { # Force this charset for compose $main::force_charset = $userconfig{'charset'}; } else { $main::force_charset = &get_charset(); } &mail_page_header($text{'compose_title'}); } else { # Replying or forwarding if ($in{'mailforward'} ne '') { # Forwarding multiple .. get the messages @mailforwardids = split(/\0/, $in{'mailforward'}); @fwdmail = &mailbox_select_mails($folder, \@mailforwardids, 0); @fwdmail || &error($text{'reply_efwdnone'}); $mail = $fwdmail[0]; } else { # Replying or forwarding one .. get it $mail = &mailbox_get_mail($folder, $in{'id'}, 0); $mail || &error($text{'view_egone'}); &decode_and_sub(); } $viewlink = "view_mail.cgi?id=".&urlize($in{'id'}). "&folder=$in{'folder'}"; $mail || &error($text{'mail_eexists'}); # Find the body parts and set the character set ($textbody, $htmlbody, $body) = &find_body($mail, $userconfig{'view_html'}); my $mail_charset = &get_mail_charset($mail, $body); if (&get_charset() eq 'UTF-8' && &can_convert_to_utf8(undef, $mail_charset)) { # Convert to UTF-8 $body->{'data'} = &convert_to_utf8($body->{'data'}, $mail_charset); $main::force_charset = 'UTF-8'; } else { # Set the character set for the page to match email $main::force_charset = $mail_charset; } if ($in{'delete'}) { # Just delete the email if (!$in{'confirm'} && &need_delete_warn($folder)) { # Need to ask for confirmation before deleting &mail_page_header($text{'confirm_title'}); print &ui_confirmation_form( "reply_mail.cgi", $text{'confirm_warn3'}."
". ($userconfig{'delete_warn'} ne 'y' ? $text{'confirm_warn2'}."

" : $folder->{'type'} == 0 ? $text{'confirm_warn4'}."

" : ""), [ &inputs_to_hiddens(\%in) ], [ [ 'confirm', $text{'confirm_ok'} ] ], ); &mail_page_footer( $viewlink, $text{'view_return'}, "index.cgi?folder=$in{'folder'}", $text{'index'}); exit; } &lock_folder($folder); &mailbox_delete_mail($folder, $mail); &unlock_folder($folder); &pop3_logout_all(); &redirect_to_previous(); exit; } elsif ($in{'markas0'} || $in{'markas1'} || $in{'markas2'}) { # Just mark the message as read/special my $oldread = &get_mail_read($folder, $mail); my $mark = $in{'markas0'} ? 0 : $in{'markas1'} ? 1 : 2; &set_mail_read($folder, $mail, ($oldread&4)+$mark); &redirect_to_previous(1); exit; } elsif ($in{'move1'} || $in{'move2'}) { # Move to another folder &error_setup($text{'reply_errm'}); my $mfolder = $folders[$in{'move1'} ? $in{'mfolder1'} : $in{'mfolder2'}]; $mfolder->{'noadd'} && &error($text{'delete_enoadd'}); &lock_folder($folder); &lock_folder($mfolder); &mailbox_move_mail($folder, $mfolder, $mail); &unlock_folder($mfolder); &unlock_folder($folder); &redirect_to_previous(); exit; } elsif ($in{'copy1'} || $in{'copy2'}) { # Copy to another folder &error_setup($text{'reply_errc'}); my $mfolder = $folders[$in{'copy1'} ? $in{'mfolder1'} : $in{'mfolder2'}]; my $qerr = &would_exceed_quota($mfolder, $mail); &error($qerr) if ($qerr); &lock_folder($folder); &lock_folder($mfolder); &mailbox_copy_mail($folder, $mfolder, $mail); &unlock_folder($mfolder); &unlock_folder($folder); &redirect_to_previous(); exit; } elsif ($in{'detach'} && $config{'server_attach'} == 2) { # Detach some attachment to a directory on the server &error_setup($text{'detach_err'}); $in{'dir'} || &error($text{'detach_edir'}); $in{'dir'} = "$remote_user_info[7]/$in{'dir'}" if ($in{'dir'} !~ /^\//); if ($in{'attach'} eq '*') { # Detaching all attachments (except the body and any # signature) under their filenames @dattach = grep { $_->{'idx'} ne $in{'bindex'} && $_->{'header'}->{'content-type'} !~ /^multipart\//i } @{$mail->{'attach'}}; if (defined($in{'sindex'})) { @dattach = grep { $_->{'idx'} ne $in{'sindex'} } @dattach; } } else { # Just one attachment @dattach = ( $mail->{'attach'}->[$in{'attach'}] ); } my @paths; foreach my $attach (@dattach) { my $path; if (-d $in{'dir'}) { # Just write to the filename in the directory my $fn; if ($attach->{'filename'}) { $fn = &decode_mimewords( $attach->{'filename'}); $fn =~ s/^.*[\/\\]//; } else { $attach->{'type'} =~ /\/(\S+)$/; $fn = "file.$1"; } $path = "$in{'dir'}/$fn"; } else { # Assume a full path was given $path = $in{'dir'}; } push(@paths, $path); } for(my $i=0; $i<@dattach; $i++) { # Try to write the files open(my $FILE, ">", "$paths[$i]") || &error(&text('detach_eopen', "$paths[$i]", $!)); (print $FILE $dattach[$i]->{'data'}) || &error(&text('detach_ewrite', "$paths[$i]", $!)); close($FILE) || &error(&text('detach_ewrite', "$paths[$i]", $!)); } # Show a message about the new files &mail_page_header($text{'detach_title'}); for(my $i=0; $i<@dattach; $i++) { my $sz = (int(length($dattach[$i]->{'data'}) / 1000)+1)." Kb"; print "

",&text('detach_ok', "$paths[$i]", $sz),"

\n"; } &mail_page_footer( $viewlink, $text{'view_return'}, "index.cgi?folder=$in{'folder'}", $text{'mail_return'}); exit; } elsif ($in{'black'} || $in{'white'}) { # Add sender to SpamAssassin black/write list, and tell user $mode = $in{'black'} ? "black" : "white"; &mail_page_header($text{$mode.'_title'}); &foreign_require("spam", "spam-lib.pl"); my $conf = &spam::get_config(); my @from = map { @{$_->{'words'}} } &spam::find($mode."list_from", $conf); my %already = map { $_, 1 } @from; my ($spamfrom) = &address_parts($mail->{'header'}->{'from'}); if ($already{$spamfrom}) { print &text($mode.'_already', "$spamfrom"),"

\n"; } else { push(@from, $spamfrom); &spam::save_directives($conf, $mode.'list_from', \@from, 1); &flush_file_lines(); print &text($mode.'_done', "$spamfrom"),"

\n"; } # Also move message to inbox $inbox = &get_spam_inbox_folder(); if ($userconfig{'white_move'} && $folder->{'spam'} && $in{'white'}) { &mailbox_move_mail($folder, $inbox, $mail); &mail_page_footer( "index.cgi?folder=$in{'folder'}&". "start=$in{'start'}", $text{'mail_return'}); } else { &mail_page_footer( $viewlink, $text{'view_return'}, "index.cgi?folder=$in{'folder'}&". "start=$in{'start'}", $text{'mail_return'}); } exit; } elsif ($in{'razor'} || $in{'ham'}) { # Report message to Razor as spam/ham and tell user $mode = $in{'razor'} ? "razor" : "ham"; &mail_page_header($text{$mode.'_title'}); print "",$text{$mode.'_report'},"\n"; print "

";
		my $temp = &transname();
		&send_mail($mail, $temp, 0, 1);

		if ($userconfig{'spam_del'} && $mode eq "razor") {
			# Delete message too
			&lock_folder($folder);
			&mailbox_delete_mail($folder, $mail);
			&unlock_folder($folder);
			}

		my $cmd = $mode eq "razor" ? &spam_report_cmd()
					   : &ham_report_cmd();
		open(my $OUT, "$cmd <$temp 2>&1 |");
		my $error;
		while(<$OUT>) {
			print &html_escape($_);
			$error++ if (/failed/i);
			}
		close($OUT);
		unlink($temp);
		print "
\n"; $deleted = 0; my $loc; if ($? || $error) { print "",$text{'razor_err'},"

\n"; } else { $inbox = &get_spam_inbox_folder(); if ($userconfig{'spam_del'} && $mode eq "razor") { # Delete message too print "$text{'razor_deleted'}

\n"; $deleted = 1; $loc = "index.cgi?folder=$in{'folder'}"; } elsif ($userconfig{'ham_move'} && $folder->{'spam'} && $in{'ham'}) { # Move mail to inbox and tell user if (&remove_spam_subject($mail)) { &mailbox_modify_mail( $mail, $mail, $folder); } &mailbox_move_mail($folder, $inbox, $mail); print "",&text('razor_moved', $inbox->{'name'}),"

\n"; $deleted = 1; $loc = "index.cgi?folder=$in{'folder'}"; } else { # Tell user it was done print "",$text{'razor_done'},"

\n"; $loc = $viewlink; } } &mail_page_footer( $deleted ? ( ) : ( $viewlink, $text{'view_return'} ), "index.cgi?folder=$in{'folder'}&start=$in{'start'}", $text{'mail_return'}); exit; } elsif ($in{'dsn'}) { # Send DSN to sender my %dsn; &open_dbm_db(\%dsn, "$user_module_config_directory/dsn", 0600); my $dsnaddr = &send_delivery_notification($mail, undef, 1); if ($dsnaddr) { my $mid = $mail->{'header'}->{'message-id'}; $dsn{$mid} = time()." ".$dsnaddr; } dbmclose(%dsn); &redirect_to_previous(); exit; } # Get the forwarded message and its attachments if (!@fwdmail) { &parse_mail($mail); &decrypt_attachments($mail); @attach = @{$mail->{'attach'}}; } if ($in{'enew'}) { # Editing an existing message, so keep same fields $to = $mail->{'header'}->{'to'}; $rto = $mail->{'header'}->{'reply-to'}; $from = &decode_mimewords($mail->{'header'}->{'from'}); $cc = $mail->{'header'}->{'cc'}; $bcc = $mail->{'header'}->{'bcc'}; $ouser = $1 if ($from =~ /^(\S+)\@/); } else { if (!$in{'forward'} && !@fwdmail) { # Replying to a message, so set To: field $to = $mail->{'header'}->{'reply-to'}; $to = $mail->{'header'}->{'from'} if (!$to); $replyfrom = $mail->{'header'}->{'to'}; } if ($in{'ereply'}) { # Replying to our own sent email - to should be # original to $to = $mail->{'header'}->{'to'}; } elsif ($in{'erall'}) { # Replying to all of our own email - set to and cc $to = $mail->{'header'}->{'to'}; $cc = $mail->{'header'}->{'cc'}; $bcc = $mail->{'header'}->{'bcc'}; } elsif ($in{'rall'}) { # If replying to all, add any addresses in the original # To: or Cc: to our new Cc: address. $cc = $mail->{'header'}->{'to'}; $cc .= ", ".$mail->{'header'}->{'cc'} if ($mail->{'header'}->{'cc'}); } } # Convert MIMEwords in headers to 8 bit for display $to = &decode_mimewords($to); $rto = &decode_mimewords($rto); $cc = &decode_mimewords($cc); $bcc = &decode_mimewords($bcc); # If replying, work out address it was sent to - this can be later used # as the from address if ($replyfrom) { $replyfrom = &decode_mimewords($replyfrom); @replyfrom = &split_addresses($replyfrom); $replyfrom = @replyfrom ? $replyfrom[0]->[0] : undef; } # Remove our own emails from to/cc addresses if (($in{'rall'} || $in{'erall'}) && !$in{'enew'} && !$userconfig{'reply_self'}) { $to = &remove_own_email($to); $cc = &remove_own_email($cc); $bcc = &remove_own_email($bcc); } # Work out new subject, depending on whether we are replying # our forwarding a message (or neither) my $qu = !$in{'enew'} && (!$in{'forward'} || !$userconfig{'fwd_mode'}); $subject = &convert_header_for_display($mail->{'header'}->{'subject'}, undef, 1); $subject = "Re: ".$subject if ($subject !~ /^Re:/i && !$in{'forward'} && !@fwdmail && !$in{'enew'}); $subject = "Fwd: ".$subject if ($subject !~ /^Fwd:/i && ($in{'forward'} || @fwdmail)); # Remove signature &check_signature_attachments($mail->{'attach'}, $textbody); # Construct the initial mail text $sig = &get_signature(); ($quote, $html_edit, $body) = "ed_message( $mail, $qu, $sig, $in{'body'}, $userconfig{'sig_mode'}); # Load images using server in replies $quote = &disable_html_images($quote, 3); # Don't include the original body as an attachment @attach = &remove_body_attachments($mail, \@attach); if (!$in{'forward'} && !$in{'enew'}) { # When replying, lose non-cid attachments @attach = grep { $_->{'header'}->{'content-id'} || $_->{'header'}->{'content-location'} } @attach; } # For a HTML reply or forward, fix up the cid: to refer to attachments # in the original message. if ($html_edit) { my $qmid = &urlize($mail->{'id'}); $quote = &fix_cids($quote, \@attach, "detach.cgi?id=$qmid&folder=$in{'folder'}$subs"); } &mail_page_header( $in{'forward'} || @fwdmail ? $text{'forward_title'} : $in{'enew'} ? $text{'enew_title'} : $text{'reply_title'}); } # Script to validate fields my $noto_msg = "e_escape($text{'send_etomsg'}, '"'); my $nosubject_msg = "e_escape($text{'send_esubjectmsg'}, '"'); my $close_msg = "e_escape($text{'send_eclosemsg'}, '"'); print < function check_fields() { form = document.forms[0]; window.submit_clicked = true; if (form.to.value == '' && form.cc.value == '' && form.bcc.value == '' && !form.draft_clicked) { alert("$noto_msg"); return false; } if (form.subject.value == '' && !form.draft_clicked) { if (!confirm("$nosubject_msg")) { return false; } } return true; } function prompt_save(event) { form = document.forms[0]; if (window.submit_clicked) { return null; } if (form.body.value != '' && form.body.value != '') { return "$close_msg"; } return null; } window.onbeforeunload = prompt_save; window.submit_clicked = false; EOF # Show form start, with upload progress tracker hook my $upid = time().$$; my ($froms, $doms); # XXX More globals. my $onsubmit = &read_parse_mime_javascript($upid, [ map { "attach$_" } (0..10) ]); $onsubmit =~ s/='/='ok = check_fields(); if (!ok) { return false; } /; if ($main::force_charset) { $onsubmit .= " accept-charset=$main::force_charset"; } print &ui_form_start("send_mail.cgi?id=$upid", "form-data", undef, $onsubmit); # Output various hidden fields print &ui_hidden("ouser", $ouser); print &ui_hidden("id", $in{'id'}); print &ui_hidden("folder", $in{'folder'}); print &ui_hidden("start", $in{'start'}); print &ui_hidden("new", $in{'new'}); print &ui_hidden("enew", $in{'enew'}); foreach my $s (@sub) { print &ui_hidden("sub", $s); } if ($in{'reply'} || $in{'rall'} || $in{'ereply'} || $in{'erall'}) { # Message ID and usermin ID being replied to print &ui_hidden("rid", $mail->{'header'}->{'message-id'}); print &ui_hidden("replyid", $mail->{'id'}); } print &ui_hidden("charset", $main::force_charset); # Start tabs for from / to / cc / bcc / signing / options # Subject is separate print &ui_table_start($text{'reply_headers'}, "width=100%", 2); print ""; my $has_gpg; my @keys; if (&has_command("gpg") && &foreign_check("gnupg") && &foreign_available("gnupg")) { &foreign_require("gnupg", "gnupg-lib.pl"); @keys = &gnupg::list_keys_sorted(); $has_gpg = @keys ? 1 : 0; } my @tabs = ( [ "from", $text{'reply_tabfrom'} ], $userconfig{'reply_to'} ne 'x' ? ( [ "rto", $text{'reply_tabreplyto'} ] ) : ( ), [ "to", $text{'reply_tabto'} ], $userconfig{'cc_tabs'} ? ( ) : ( [ "cc", $text{'reply_tabcc'} ], [ "bcc", $text{'reply_tabbcc'} ] ), $has_gpg ? ( [ "signing", $text{'reply_tabsigning'} ] ) : ( ), [ "options", $text{'reply_taboptions'} ] ); print &ui_tabs_start(\@tabs, "tab", "to", 0); # From address tab my @froms; if ($from) { # Got From address already, such as when editing old email @froms = ( $from ); } else { # Work out From: addresses ($froms, $doms) = &list_from_addresses(); @froms = @$froms; } # Find preferred From address from addressbook, if set my @faddrs = grep { $_->[3] } &list_addresses(); my ($defaddr) = grep { $_->[3] == 2 } @faddrs; # If replying to an email and the original to address is in our addressbook, # use that as the from address my $replyaddr; if ($replyfrom) { ($replyaddr) = grep { $_->[0] eq $replyfrom } @faddrs; $defaddr = $replyaddr if ($replyaddr); } if ($folder->{'fromaddr'}) { # Folder has a specified From: address ($defaddr) = &split_addresses($folder->{'fromaddr'}); } my $deffrom; my $frominput; if ($config{'edit_from'} == 1) { # User can enter any from address he wants if ($defaddr) { # Address book contains a default from address $deffrom = $defaddr->[1] ? "\"$defaddr->[1]\" <$defaddr->[0]>" : $defaddr->[0]; } else { $deffrom = $froms[0]; } $frominput = &ui_address_field("from", $deffrom, 1, 0); } elsif ($config{'edit_from'} == 2) { # Only the real name and username part is editable my ($real, $user, $dom); my ($sp) = $defaddr || &split_addresses($froms[0]); $real = $sp->[1]; if ($sp->[0] =~ /^(\S+)\@(\S+)$/) { $user = $1; $dom = $2; } else { $user = $sp->[0]; } $frominput = &ui_textbox("real", $real, 15)."\n". "<".&ui_textbox("user", $user, 10)."\@"; if ($doms && @$doms > 1) { $frominput .= &ui_select("dom", undef, [ map { [ $_ ] } @$doms ]).">"; } else { $frominput .= "$dom>". &ui_hidden("dom", $dom); } $frominput .= &address_button("user", 0, 2, "real") if (@faddrs); } else { # A fixed From address, or a choice of fixed options if (@froms > 1) { $deffrom = $froms[0]; if ($replyfrom) { # Use from address from original email if possible foreach my $f (@froms) { my @f = &split_addresses($f); if (@f && $f[0]->[0] eq $replyfrom) { $deffrom = $f; last; } } } $frominput = &ui_select("from", $deffrom, [ map { [ $_, &html_escape($_) ] } @froms ]); } else { $frominput = "".&html_escape($froms[0])."". &ui_hidden("from", $froms[0]); } } print &ui_tabs_start_tab("tab", "from"); print &ui_div_row($text{'mail_from'}, $frominput); print &ui_tabs_end_tab(); # Show the Reply-To field if ($userconfig{'reply_to'} ne 'x') { $rto = $userconfig{'reply_to'} if ($userconfig{'reply_to'} ne '*'); print &ui_tabs_start_tab("tab", "rto"); print &ui_div_row($text{'mail_replyto'}, &ui_address_field("replyto", $rto, 1, 0)); print &ui_tabs_end_tab(); } $bcc ||= $userconfig{'bcc_to'}; if ($userconfig{'cc_tabs'}) { # Show all address fields in a tab print &ui_tabs_start_tab("tab", "to"); print &ui_div_row($text{'mail_to'}, &ui_address_field("to", $to, 0, 1)); print &ui_div_row($text{'mail_cc'}, &ui_address_field("cc", $cc, 0, 1)); print &ui_div_row($text{'mail_bcc'}, &ui_address_field("bcc", $bcc, 0, 1)); print &ui_tabs_end_tab(); } else { # Show To: field in a tab print &ui_tabs_start_tab("tab", "to"); print &ui_div_row($text{'mail_to'}, &ui_address_field("to", $to, 0, 1)); print &ui_tabs_end_tab(); # Show Cc: field in a tab print &ui_tabs_start_tab("tab", "cc"); print &ui_div_row($text{'mail_cc'}, &ui_address_field("cc", $cc, 0, 1)); print &ui_tabs_end_tab(); # Show Bcc: field in a tab print &ui_tabs_start_tab("tab", "bcc"); print &ui_div_row($text{'mail_bcc'}, &ui_address_field("bcc", $bcc, 0, 1)); print &ui_tabs_end_tab(); } # Ask for signing and encryption if ($has_gpg) { print &ui_tabs_start_tab("tab", "signing"); my @signs; my $def_sign = ""; my @crypts; foreach my $k (@keys) { my $n = $k->{'name'}->[0]; $n = substr($n, 0, 40)."..." if (length($n) > 40); if ($k->{'email'}->[0]) { $n .= " <".$k->{'email'}->[0].">"; } else { $n .= " ($k->{'key'})"; } if ($k->{'secret'}) { push(@signs, [ $k->{'index'}, $n ]); } if ($k->{'secret'} && $userconfig{'def_sign'}) { my $def_signer = lc($userconfig{'def_sign'}); for(my $i=0; $i<@{$k->{'name'}}; $i++) { if (lc($k->{'name'}->[$i]) eq $def_signer || lc($k->{'email'}->[$i]) eq $def_signer) { $def_sign = $k->{'index'}; } } } push(@crypts, [ $k->{'index'}, $n ]); } print &ui_div_row($text{'mail_sign'}, &ui_select("sign", $def_sign, [ [ "", $text{'mail_nosign'} ], @signs ])); print &ui_div_row($text{'mail_crypt'}, &ui_select("crypt", $userconfig{'def_crypt'} ? -1 : "", [ [ "", $text{'mail_nocrypt'} ], [ -1, $text{'mail_samecrypt'} ], @crypts ])); print &ui_tabs_end_tab(); } # Show tab for options print &ui_tabs_start_tab("tab", "options"); print &ui_div_row($text{'mail_pri'}, &ui_select("pri", "", [ [ 1, $text{'mail_highest'} ], [ 2, $text{'mail_high'} ], [ "", $text{'mail_normal'} ], [ 4, $text{'mail_low'} ], [ 5, $text{'mail_lowest'} ] ])); if ($userconfig{'req_dsn'} == 2) { # Ask for a disposition (read) status print &ui_div_row($text{'reply_dsn'}, &ui_radio("dsn", 0, [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ])); } if ($userconfig{'req_del'} == 2) { # Ask for a delivery status print &ui_div_row($text{'reply_del'}, &ui_radio("del", 0, [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ])); } # Ask if should add to address book print &ui_div_row(" ", &ui_checkbox("abook", 1, $text{'reply_aboot'}, $userconfig{'add_abook'})); print &ui_tabs_end_tab(); print &ui_tabs_end(); # JS to disable enter in subject field print < function noenter() { return !(window.event && window.event.keyCode == 13); } EOF # Field for subject is always at the bottom if ($userconfig{'send_buttons'}) { print &ui_div_row($text{'mail_subject'}, &ui_textbox("subject", $subject, 40, 0, undef, "style='width:50%' onKeyPress='return noenter()'"). "  ".&ui_submit($text{'reply_send'}). &ui_submit($text{'reply_draft'}, "draft", undef, "onClick='form.draft_clicked = 1'"). &ui_submit($text{'reply_save'}, "save", undef, "onClick='form.draft_clicked = 1'")); } else { # Subject only print &ui_div_row($text{'mail_subject'}, &ui_textbox("subject", $subject, 40, 0, undef, "style='width:90%' onKeyPress='return noenter()'")); } print ""; print &ui_table_end(); # Create link for switching to HTML/text mode for new mail my @bodylinks; if ($in{'new'}) { if ($html_edit) { push(@bodylinks, "$text{'reply_html0'}"); } else { push(@bodylinks, "$text{'reply_html1'}"); } } # Output message body input print &ui_table_start($text{'reply_body'}, "width=100%", 2, undef, &ui_links_row(\@bodylinks)); # Process email quote my $iframe_quote; $iframe_quote = &iframe_quote($quote) if (!$in{'new'} && !$in{'enew'}); my $draft; $draft = $quote if ($in{'new'} || $in{'enew'}); if ($html_edit) { # Get HTML editor and replies my $html_editor = &html_editor( { textarea => { target => { name => 'body', attr => 'name' }, sync => { position => 'after', data => [ { iframe => '#quote-mail-iframe', elements => ['#webmin-iframe-quote'] } ] } }, type => $userconfig{'html_edit_mode'} || 'simple', after => { editor => $iframe_quote } }); # Output HTML editor textarea $sig =~ s/\n/
/g, $sig =~ s/^\s+//g, $sig = "

$sig

" if ($sig); print &ui_table_row(undef, &ui_textarea("body", $draft || $sig, 16, 80, undef, 0, "style='display: none' id=body data-html-mode='$userconfig{'html_edit_mode'}'"). $html_editor, 2); } else { # Show text editing area my $wm = $config{'wrap_mode'}; $wm =~ s/^wrap=//g; my $wcols = $userconfig{'wrap_compose'}; print &ui_table_row(undef, &ui_textarea("body", "\n".($draft || "\n\n$sig\n\n$quote"), 16, $wcols || 80, $wcols ? "hard" : "", 0, $wcols ? "" : "style='width:100%'"), 2); } if (&has_command("ispell") && !$userconfig{'nospellcheck'}) { print &ui_table_row(undef, &ui_checkbox("spell", 1, $text{'reply_spell'}, $userconfig{'spell_check'}), 2); } print &ui_table_end(); print &ui_hidden("html_edit", $html_edit); print &ui_hidden("html_edit_config", $userconfig{'html_edit'}); # Display forwarded attachments - but exclude those referenced in the body, # as they get included automatically my $viewurl = "view_mail.cgi?id=".&urlize($in{'id'}). "&folder=$folder->{'index'}$subs"; my $detachurl = "detach.cgi?id=".&urlize($in{'id'}). "&folder=$folder->{'index'}$subs"; my $mailurl = "view_mail.cgi?folder=$folder->{'index'}$subs"; my @non_body_attach; if (@attach) { @non_body_attach = &remove_cid_attachments($mail, \@attach); } if (@non_body_attach) { &attachments_table(\@non_body_attach, $folder, $viewurl, $detachurl, $mailurl, 'id', "forward"); } foreach my $a (@attach) { if (&indexof($a, @non_body_attach) < 0) { # Body attachment .. always include print &ui_hidden("forward", $a->{'idx'}); } } # Display forwarded mails if (@fwdmail) { &attachments_table(\@fwdmail, $folder, $viewurl, $detachurl, $mailurl, 'id', undef); foreach my $fwdid (@mailforwardids) { print &ui_hidden("mailforward", $fwdid); } } # Display new attachment fields &show_attachments_fields($userconfig{'def_attach'}, $config{'server_attach'}); print &ui_form_end([ [ "send", $text{'reply_send'} ], [ "draft", $text{'reply_draft'}, undef, undef, "onClick='form.draft_clicked = 1'" ], [ "save", $text{'reply_save'}, undef, undef, "onClick='form.draft_clicked = 1'" ], ]); &mail_page_footer("index.cgi?folder=$in{'folder'}&start=$in{'start'}", $text{'mail_return'}); &pop3_logout_all(); sub decode_and_sub { return if (!$mail); &parse_mail($mail); @sub = split(/\0/, $in{'sub'}); $subs = join("", map { "&sub=$_" } @sub); my ($deccode, $decmessage); foreach my $s (@sub) { # We are looking at a mail within a mail .. &decrypt_attachments($mail); my $amail = &extract_mail( $mail->{'attach'}->[$s]->{'data'}); &parse_mail($amail); $mail = $amail; } ($deccode, $decmessage) = &decrypt_attachments($mail); } sub redirect_to_previous { my ($refresh) = @_; $refresh = time().$$ if ($refresh); my $perpage = $folder->{'perpage'} || $userconfig{'perpage'}; my $s = int($mail->{'sortidx'} / $perpage) * $perpage; if ($userconfig{'open_mode'}) { &redirect($viewlink); } else { &redirect("index.cgi?folder=$in{'folder'}&start=$s&refresh=$refresh"); } }