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

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 });
}