Add setting for catch all address

Note that this is not a flag on the mailboxes because we might theoretically
support forwarding to some other external domain in the future.

Part of #33
This commit is contained in:
Girish Ramakrishnan
2017-06-11 17:51:08 -07:00
parent da7648fe3f
commit 0cc980f539
7 changed files with 174 additions and 7 deletions

View File

@@ -239,16 +239,22 @@ function createMailConfig(callback) {
const mailFqdn = config.adminFqdn();
const alertsFrom = 'no-reply@' + config.fqdn();
debug('createMailConfig: generating mail config');
user.getOwner(function (error, owner) {
var alertsTo = config.provider() === 'caas' ? [ 'support@cloudron.io' ] : [ ];
alertsTo.concat(error ? [] : owner.email).join(',');
if (!safe.fs.writeFileSync(paths.ADDON_CONFIG_DIR + '/mail/mail.ini',
`mail_domain=${fqdn}\nmail_server_name=${mailFqdn}\nalerts_from=${alertsFrom}\nalerts_to=${alertsTo}`, 'utf8')) {
return callback(new Error('Could not create mail var file:' + safe.error.message));
}
settings.getCatchAllAddress(function (error, address) {
var catchAll = address.join(',');
callback();
if (!safe.fs.writeFileSync(paths.ADDON_CONFIG_DIR + '/mail/mail.ini',
`mail_domain=${fqdn}\nmail_server_name=${mailFqdn}\nalerts_from=${alertsFrom}\nalerts_to=${alertsTo}\ncatch_all=${catchAll}\n`, 'utf8')) {
return callback(new Error('Could not create mail var file:' + safe.error.message));
}
callback();
});
});
}