mail: add option to force from address for relays

This commit is contained in:
Girish Ramakrishnan
2021-10-16 21:47:23 -07:00
parent 273a833935
commit 22e4d956fb
3 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ exports = module.exports = {
'postgresql': { repo: 'cloudron/postgresql', tag: 'cloudron/postgresql:4.1.1@sha256:86e4e2f4fd43809efca7c9cb1def4d7608cf36cb9ea27052f9b64da4481db43a' },
'mongodb': { repo: 'cloudron/mongodb', tag: 'cloudron/mongodb:4.0.2@sha256:9df297ccc3370f38c54f8d614e214e082b363777cd1c6c9522e29663cc8f5362' },
'redis': { repo: 'cloudron/redis', tag: 'cloudron/redis:3.0.4@sha256:5c60de75d078ae609da5565f32dcd91030f45907e945756cc976ff207b8c6199' },
'mail': { repo: 'cloudron/mail', tag: 'cloudron/mail:3.4.0@sha256:f484702cea26915b9a2501e11710d8975460c5070ee0b7175ae9afc788512f0e' },
'mail': { repo: 'cloudron/mail', tag: 'cloudron/mail:3.4.0@sha256:5f9795cad3634c177f789019c12f8d53a6481de3cc627fb5a4866ce085006507' },
'graphite': { repo: 'cloudron/graphite', tag: 'cloudron/graphite:3.0.1@sha256:bed9f6b5d06fe2c5289e895e806cfa5b74ad62993d705be55d4554a67d128029' },
'sftp': { repo: 'cloudron/sftp', tag: 'cloudron/sftp:3.4.1@sha256:13e066fcd52230f23244c16fdd2f7aa447a91e98ff703269f48b1afe3b393e31' }
}
+6 -4
View File
@@ -659,12 +659,14 @@ async function createMailConfig(mailFqdn, mailDomain) {
port = relay.port || 25,
authType = relay.username ? 'plain' : '',
username = relay.username || '',
password = relay.password || '';
password = relay.password || '',
forceFromAddress = relay.forceFromAddress ? 'true' : 'false';
if (!enableRelay) continue;
if (!safe.fs.appendFileSync(paths.MAIL_CONFIG_DIR + '/smtp_forward.ini',
`[${domain.domain}]\nenable_outbound=true\nhost=${host}\nport=${port}\nenable_tls=true\nauth_type=${authType}\nauth_user=${username}\nauth_pass=${password}\n\n`, 'utf8')) {
const relayData = `[${domain.domain}]\nenable_outbound=true\nhost=${host}\nport=${port}\nenable_tls=true\nauth_type=${authType}\nauth_user=${username}\nauth_pass=${password}\nforce_from_address=${forceFromAddress}\n\n`;
if (!safe.fs.appendFileSync(paths.MAIL_CONFIG_DIR + '/smtp_forward.ini', relayData, 'utf8')) {
throw new BoxError(BoxError.FS_ERROR, `Could not create mail var file: ${safe.error.message}`);
}
}
@@ -1042,7 +1044,7 @@ async function setMailRelay(domain, relay, options) {
if (error) throw error;
}
await updateDomain(domain, { relay: relay });
await updateDomain(domain, { relay });
safe(restartMail(), { debug });
}
+1
View File
@@ -100,6 +100,7 @@ async function setMailRelay(req, res, next) {
if ('username' in req.body && typeof req.body.username !== 'string') return next(new HttpError(400, 'username must be a string'));
if ('password' in req.body && typeof req.body.password !== 'string') return next(new HttpError(400, 'password must be a string'));
if ('acceptSelfSignedCerts' in req.body && typeof req.body.acceptSelfSignedCerts !== 'boolean') return next(new HttpError(400, 'acceptSelfSignedCerts must be a boolean'));
if ('forceFromAddress' in req.body && typeof req.body.forceFromAddress !== 'boolean') return next(new HttpError(400, 'forceFromAddress must be a boolean'));
const [error] = await safe(mail.setMailRelay(req.params.domain, req.body, { skipVerify: false }));
if (error) return next(BoxError.toHttpError(error));