Add a show_message_size_by_attachment option.

This makes the message too large errors show the size as a "realistic" size more understandable by laypeople - i.e. it divides the message size limit by 1.33 to show the maximum size after base64-ing attachments, rather than the maximum size assume the whole message is text.
pull/7342/head
Nathan Ward 4 years ago
parent b35b5a1a26
commit 69b68645b5

@ -587,6 +587,10 @@ $config['sendmail_delay'] = 0;
// Size in bytes (possible unit suffix: K, M, G)
$config['max_message_size'] = '100M';
// Show message size by the attachable size in errors. i.e. the above limit
// divided by 1.33 to account for base64 encoding.
$config['show_message_size_by_attachment'] = false;
// Maximum number of recipients per message (including To, Cc, Bcc).
// Default: 0 (no limit)
$config['max_recipients'] = 0;

@ -278,7 +278,11 @@ function rcmail_check_message_size($filesize, $filetype)
$size += $filesize * $multip;
if ($size > $limit) {
$limit = $RCMAIL->show_bytes($limit);
if ($RCMAIL->config->get('show_message_size_by_attachment')) {
$limit = $RCMAIL->show_bytes($limit/1.33);
} else {
$limit = $RCMAIL->show_bytes($limit);
}
return $RCMAIL->gettext(array('name' => 'msgsizeerror', 'vars' => array('size' => $limit)));
}
}

@ -1136,7 +1136,11 @@ function rcmail_write_forward_attachments()
}
if ($size_errors) {
$limit = $RCMAIL->show_bytes($size_limit);
if ($RCMAIL->config->get('show_message_size_by_attachment')) {
$limit = $RCMAIL->show_bytes($size_limit/1.33);
} else {
$limit = $RCMAIL->show_bytes($size_limit);
}
$error = $RCMAIL->gettext(array('name' => 'msgsizeerrorfwd', 'vars' => array('num' => $size_errors, 'size' => $limit)));
$RCMAIL->output->add_script(sprintf("%s.display_message('%s', 'error');", rcmail_output::JS_OBJECT_NAME, rcube::JQ($error)), 'docready');
}

Loading…
Cancel
Save