@@ -32,6 +32,7 @@ var assert = require('assert'),
|
||||
DomainsError = require('./domains.js').DomainsError,
|
||||
df = require('@sindresorhus/df'),
|
||||
fs = require('fs'),
|
||||
mail = require('./mail.js'),
|
||||
mailer = require('./mailer.js'),
|
||||
os = require('os'),
|
||||
path = require('path'),
|
||||
@@ -302,6 +303,8 @@ function setDashboardDomain(domain, callback) {
|
||||
clients.addDefaultClients(config.adminOrigin(), function (error) {
|
||||
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
|
||||
|
||||
mail.setMailFqdn(fqdn, domain, NOOP_CALLBACK);
|
||||
|
||||
callback(null);
|
||||
});
|
||||
});
|
||||
|
||||
25
src/mail.js
25
src/mail.js
@@ -11,6 +11,7 @@ exports = module.exports = {
|
||||
clearDomains: clearDomains,
|
||||
|
||||
setDnsRecords: setDnsRecords,
|
||||
setMailFqdn: setMailFqdn,
|
||||
|
||||
validateName: validateName,
|
||||
|
||||
@@ -569,7 +570,6 @@ function configureMail(mailFqdn, mailDomain, callback) {
|
||||
const memoryLimit = 4 * 256;
|
||||
const cloudronToken = hat(8 * 128), relayToken = hat(8 * 128);
|
||||
|
||||
// admin and mail share the same certificate
|
||||
reverseProxy.getCertificate(mailFqdn, mailDomain, function (error, bundle) {
|
||||
if (error) return callback(error);
|
||||
|
||||
@@ -617,11 +617,6 @@ function configureMail(mailFqdn, mailDomain, callback) {
|
||||
function restartMail(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
// mail (note: 2525 is hardcoded in mail container and app use this port)
|
||||
// MAIL_SERVER_NAME is the hostname of the mailserver i.e server uses these certs
|
||||
// MAIL_DOMAIN is the domain for which this server is relaying mails
|
||||
// mail container uses /app/data for backed up data and /run for restart-able data
|
||||
|
||||
if (process.env.BOX_ENV === 'test' && !process.env.TEST_CREATE_INFRA) return callback();
|
||||
|
||||
configureMail(config.mailFqdn(), config.adminDomain(), callback);
|
||||
@@ -800,6 +795,24 @@ function setDnsRecords(domain, mailFqdn, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function setMailFqdn(mailFqdn, mailDomain, callback) {
|
||||
assert.strictEqual(typeof mailFqdn, 'string');
|
||||
assert.strictEqual(typeof mailDomain, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
domains.getAll(function (error, allDomains) {
|
||||
if (error) return callback(new MailError(MailError.INTERNAL_ERROR, error));
|
||||
|
||||
async.eachOfSeries(allDomains, function (domainObject, idx, iteratorDone) {
|
||||
setDnsRecords(domainObject.domain, mailFqdn, iteratorDone);
|
||||
}, function (error) {
|
||||
if (error) return callback(new MailError(MailError.EXTERNAL_ERROR, error.message));
|
||||
|
||||
configureMail(mailFqdn, mailDomain, callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function addDomain(domain, callback) {
|
||||
assert.strictEqual(typeof domain, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
Reference in New Issue
Block a user