From 37c8ca7617ddbe3796a5c3ca4e7d9fc5a89a4dc1 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Mon, 31 Jan 2022 16:55:45 -0800 Subject: [PATCH] mail: use port25check.cloudron.io to check outbound port 25 connectivity --- CHANGES | 1 + src/constants.js | 2 ++ src/mail.js | 15 +++++---------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index b26cdb9c3..f4c33aa01 100644 --- a/CHANGES +++ b/CHANGES @@ -2416,4 +2416,5 @@ * Add support for secondary domains * postgresql: enable postgis * remove nginx config of stopped apps +* mail: use port25check.cloudron.io to check outbound port 25 connectivity diff --git a/src/constants.js b/src/constants.js index 8b55ff805..d4085413b 100644 --- a/src/constants.js +++ b/src/constants.js @@ -61,6 +61,8 @@ exports = module.exports = { CLOUDRON: CLOUDRON, TEST: TEST, + PORT25_CHECK_SERVER: 'port25check.cloudron.io', + SUPPORT_EMAIL: 'support@cloudron.io', USER_DIRECTORY_LDAP_DN: 'cn=admin,ou=system,dc=cloudron', diff --git a/src/mail.js b/src/mail.js index 466078104..88c665e6c 100644 --- a/src/mail.js +++ b/src/mail.js @@ -169,11 +169,6 @@ function validateName(name) { } async function checkOutboundPort25() { - const smtpServer = _.sample([ - 'smtp.gmail.com', - 'smtp.1und1.de', - ]); - const relay = { value: 'OK', status: false, @@ -183,7 +178,7 @@ async function checkOutboundPort25() { return await new Promise((resolve) => { const client = new net.Socket(); client.setTimeout(5000); - client.connect(25, smtpServer); + client.connect(25, constants.PORT25_CHECK_SERVER); client.on('connect', function () { relay.status = true; relay.value = 'OK'; @@ -192,16 +187,16 @@ async function checkOutboundPort25() { }); client.on('timeout', function () { relay.status = false; - relay.value = `Connect to ${smtpServer} timed out. Check if port 25 (outbound) is blocked`; + relay.value = `Connect to ${constants.PORT25_CHECK_SERVER} timed out. Check if port 25 (outbound) is blocked`; client.destroy(); - relay.errorMessage = `Connect to ${smtpServer} timed out.`; + relay.errorMessage = `Connect to ${constants.PORT25_CHECK_SERVER} timed out.`; resolve(relay); }); client.on('error', function (error) { relay.status = false; - relay.value = `Connect to ${smtpServer} failed: ${error.message}. Check if port 25 (outbound) is blocked`; + relay.value = `Connect to ${constants.PORT25_CHECK_SERVER} failed: ${error.message}. Check if port 25 (outbound) is blocked`; client.destroy(); - relay.errorMessage = `Connect to ${smtpServer} failed.`; + relay.errorMessage = `Connect to ${constants.PORT25_CHECK_SERVER} failed.`; resolve(relay); }); });