diff -Naur mantisbt-1.2.3/config_defaults_inc.php mantisbt-patch/config_defaults_inc.php --- mantisbt-1.2.3/config_defaults_inc.php 2010-09-21 09:16:10.000000000 +0200 +++ mantisbt-patch/config_defaults_inc.php 2010-09-21 09:16:26.000000000 +0200 @@ -483,6 +483,12 @@ $g_phpMailer_method = PHPMAILER_METHOD_MAIL; /** + * select the e-mail max length (in x1024 characters). Length is unlimited if set to 0. + * @global int $g_email_max_length + */ + $g_email_max_length = 0; + + /** * This option allows you to use a remote SMTP host. Must use the phpMailer script * One or more hosts, separated by a semicolon, can be listed. * You can also specify a different port for each host by using this diff -Naur mantisbt-1.2.3/core/email_api.php mantisbt-patch/core/email_api.php --- mantisbt-1.2.3/core/email_api.php 2010-09-21 09:16:56.000000000 +0200 +++ mantisbt-patch/core/email_api.php 2010-09-21 09:17:08.000000000 +0200 @@ -871,7 +871,7 @@ $t_recipient = trim( $t_email_data->email ); $t_subject = string_email( trim( $t_email_data->subject ) ); - $t_message = string_email_links( trim( $t_email_data->body ) ); + $t_message = string_email_links( cut_long_email( trim( $t_email_data->body ) ) ); $t_debug_email = config_get( 'debug_email' ); $t_mailer_method = config_get( 'phpMailer_method' ); @@ -1014,6 +1014,28 @@ } /** + * cut overlengthed emails + * + * @param string + * @return string + */ +function cut_long_email( $p_string ) { + $t_max_len = config_get( 'email_max_length' ) * 1024; + $t_string = $p_string; + $t_cut_end = "\n\n(...)"; + if( $t_max_len > 0 && strlen( $t_string ) > $t_max_len ) { + $t_string = substr( $t_string, 0, $t_max_len - strlen( $t_cut_end ) ); + $t_pos = strrpos( $t_string, "\n" ); + if($t_pos !== false && $t_pos > 0) { + # Clean cut at end of line + $t_string = substr( $t_string, 0, $t_pos ); + } + $t_string .= $t_cut_end; + } + return $t_string; +} + +/** * closes opened kept alive SMTP connection (if it was opened) * * @param string