Skip to content

Commit 0fa0448

Browse files
committed
Add configurable SMTP message size limit
Replace hardcoded 20MB SMTP message size limit with configurable option. The new configuration allows users to adjust the maximum message size accepted by the built-in SMTP server to match their mail server limits. Changes: - Add DEFAULT_MAX_SMTP_MESSAGE_SIZE constant (25MB default) - Implement EENGINE_MAX_SMTP_MESSAGE_SIZE environment variable - Add smtp.maxMessageSize configuration option - Update help.txt with new --smtp.maxMessageSize option - Add configuration example to default.toml Configuration options (in priority order): 1. Environment variable: EENGINE_MAX_SMTP_MESSAGE_SIZE=35M 2. Config file: [smtp] maxMessageSize = "35M" 3. Command line: --smtp.maxMessageSize=35M 4. Default: 25MB This addresses issues where users with larger mail server limits (e.g., Exchange Online 35MB) were unable to send messages through EmailEngine SMTP server due to the previous hardcoded 20MB limit.
1 parent 246ceb1 commit 0fa0448

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

config/default.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ port = 2525
2727
host = "127.0.0.1"
2828
secret = "" # client password, if not set allows any password
2929
proxy = false # Set to true if using HAProxy with send-proxy option
30+
#maxMessageSize = "25M" # maximum message size accepted by SMTP server (default: 25MB)
3031

3132
[dbs]
3233
# redis connection

help.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ Options:
4141
--queues.submit Submit concurrency count [number] [default: 1]
4242

4343
Submission SMTP server:
44-
--smtp.enabled Is SMTP submission server enabled [boolean] [default: false]
45-
--smtp.secret SMTP password for all accounts [string]
46-
--smtp.host Host to bind to [string] [default: "127.0.0.1"]
47-
--smtp.port Port to bind to [number] [default: 2525]
48-
--smtp.proxy Is the SMTP server hehind HAProxy [boolean] [default: false]
44+
--smtp.enabled Is SMTP submission server enabled
45+
[boolean] [default: false]
46+
--smtp.secret SMTP password for all accounts [string]
47+
--smtp.host Host to bind to [string] [default: "127.0.0.1"]
48+
--smtp.port Port to bind to [number] [default: 2525]
49+
--smtp.proxy Is the SMTP server hehind HAProxy
50+
[boolean] [default: false]
51+
--smtp.maxMessageSize Max message size [number/string] [default: "25M"]
4952

5053
"emailengine encrypt" additional options:
5154
--decrypt Old secret for decrypting (can be issued multiple times) [string]

lib/consts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ module.exports = {
110110

111111
DEFAULT_EENGINE_TIMEOUT: 10 * 1000,
112112
DEFAULT_MAX_ATTACHMENT_SIZE: 5 * 1024 * 1024,
113+
DEFAULT_MAX_SMTP_MESSAGE_SIZE: 25 * 1024 * 1024, // 25MB
113114

114115
// IF IMAP authentications fail more than provided value, then disable IMAP for the account
115116
DEFAULT_MAX_IMAP_AUTH_FAILURE_TIME: 3 * 24 * 3600 * 1000, // 3 days

workers/smtp.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const packageData = require('../package.json');
66
const config = require('wild-config');
77
const logger = require('../lib/logger');
88

9-
const { getDuration, emitChangeEvent, readEnvValue, matchIp, threadStats, loadTlsConfig } = require('../lib/tools');
9+
const { getDuration, emitChangeEvent, readEnvValue, matchIp, threadStats, loadTlsConfig, getByteSize } = require('../lib/tools');
1010

1111
const Bugsnag = require('@bugsnag/js');
1212
if (readEnvValue('BUGSNAG_API_KEY')) {
@@ -54,13 +54,13 @@ config.smtp = config.smtp || {
5454

5555
config.service = config.service || {};
5656

57-
const MAX_SIZE = 20 * 1024 * 1024;
57+
const { REDIS_PREFIX, DEFAULT_MAX_SMTP_MESSAGE_SIZE } = require('../lib/consts');
58+
5859
const DEFAULT_EENGINE_TIMEOUT = 10 * 1000;
5960

61+
const MAX_SMTP_MESSAGE_SIZE = getByteSize(readEnvValue('EENGINE_MAX_SMTP_MESSAGE_SIZE') || config.smtp.maxMessageSize) || DEFAULT_MAX_SMTP_MESSAGE_SIZE;
6062
const EENGINE_TIMEOUT = getDuration(readEnvValue('EENGINE_TIMEOUT') || config.service.commandTimeout) || DEFAULT_EENGINE_TIMEOUT;
6163

62-
const { REDIS_PREFIX } = require('../lib/consts');
63-
6464
const ACCOUNT_CACHE = new WeakMap();
6565

6666
let callQueue = new Map();
@@ -281,7 +281,7 @@ async function init() {
281281
logger: smtpLogger,
282282
disableReverseLookup: true,
283283
banner: 'EmailEngine MSA',
284-
size: MAX_SIZE,
284+
size: MAX_SMTP_MESSAGE_SIZE,
285285
useProxy: await settings.get('smtpServerProxy')
286286
};
287287

0 commit comments

Comments
 (0)