fix(smtp): reject the relay when the outgoing server cannot be reached

SMTPConnection only calls the connect() callback once the handshake
succeeds; a refused or timed out connection is emitted as an 'error'
event, which was only logged. relay() then never settled, so its finally
block (which now releases the email stream) never ran, auto-relay held
the incoming SMTP transaction open without a reply, and the REST relay
request hung. Reject the connect promise from the 'error' handler.
This commit is contained in:
dualfroz committed 2026-10-02 15:59:20 +02:00
1 parent 5479067fab
commit 53640c6990
3 files changed
+22

No files matched your search

+2
View File
@@ -160,8 +160,10 @@ export class RelayClient {
debug: false,
})
// A failed connection is reported here, not through the connect callback
this.client.on('error', (err: Error) => {
this.logger.error('SMTP Connection error:', err)
reject(err)
})
this.client.connect((err?: Error) => {