Exim and Roundcube Message Limit

I’m facing an issue and need some help.

I want to restrict my users to sending a maximum of 25MB through Roundcube. I’ve accessed the Roundcube settings and set a custom limit in the file, but I’m still encountering difficulties.

In the file /var/lib/roundcube/.user.ini, I’ve added:

upload_max_filesize = 25M
post_max_size = 25M

So far, so good. Roundcube is displaying these settings to the user. However, I’m aware that I also need to adjust this limit in Exim. This is because of the base64 encoding that occurs before the message is sent, significantly increasing its size.

Therefore, I’ve set in the Exim configuration file, located at /etc/exim4/exim4.conf.template, the size to:

message_size_limit = 35M

I’m happy with this configuration, but the problem arises when the user exceeds the limit. The message displayed to them informs that they’ve exceeded the 35MB limit, not the 25MB one. I understand that this happens because Roundcube gets the message from Exim.

I’d like to know if anyone can help me customize this Exim return message so that when the user exceeds the limit, it shows 25MB in Roundcube instead of 35MB.

Thank you.

Roundcube gets the size from the SMTP service extensions, in this case by the SIZE advertised by your mail server.

telnet mail.example.net 25
Trying 203.0.113.55...
Connected to mail.example.net.
Escape character is '^]'.
220 mail.example.net
ehlo test
250-mail.example.net Hello example.com [192.0.2.123]
250-SIZE 36700160  <---- Roundcube takes the size limit from here
250-8BITMIME
250-PIPELINING
250-PIPECONNECT
250-AUTH PLAIN LOGIN
250-CHUNKING
250-STARTTLS
250 HELP
quit
221 mail.example.net closing connection
Connection closed by foreign host.

So if you want to change the message, you must do it in Roundcube, you can:

Option 1

Modify localized error messages and replace ($limit) by 25 MB.

Example for pt_BR

Edit file /var/lib/roundcube/program/localization/pt_BR/messages.inc and replace this:

$messages['smtpsizeerror'] = 'Erro de SMTP: Tamanho da mensagem excede o limite do servidor ($limit)';

by this:

$messages['smtpsizeerror'] = 'Erro de SMTP: Tamanho da mensagem excede o limite do servidor (25 MB)';

Option 2

Modify /var/lib/roundcube/program/lib/Roundcube/rcube_smtp.php and replace:

Note: in my roundcube version 1.6.7 is line number 349.

$err_vars['limit'] = $limit;

by:

$err_vars['limit'] = '25 MB';
1 Like

Man, you saved me! Thank you so much, Sahsanu.

It worked perfectly. Due to other software that uses my SMTP server, I can’t make that change, hence the need for customization.

Thank you very much.

1 Like

You are welcome :wink:

The bad news is that you should perform the same changes the next time roundcube updates… because files will be overriden.

1 Like

True, lol

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.