Description:
In the file located at apps/meteor/server/email-inbox/EmailInbox_Outgoing.ts . Before the email is confirmed sent. If SMTP fails, the message in the DB already shows the To: / Subject: context blocks as if the email was sent , but it was never delivered. So the message record in the database is updated to reflect a sent state regardless of whether the email was actually delivered.
Steps to reproduce:
Prerequisites:
- A running RocketChat instance (tested on 8.3.0-develop)
- An SMTP test server running on localhost:1025 (e.g. maildev)
- Dovecot or equivalent IMAP server on localhost:143
- An Email Inbox configured in Admin then Email Inboxes with:
-
SMTP server: localhost, port: 1025, secure: false
-
IMAP server: localhost, port: 143, secure: false
-
reproduction:
Drop a raw email into the IMAP mailbox to trigger onEmailReceived:
sudo bash -c 'cat >> /var/mail/imaptest << EOF
From visitor@test.com Sat Mar 07 18:00:00 2026
From: visitor@test.com
To: test@example.com
Subject: Bug Test Room
Message-ID: <test-bug-001@test.com>
MIME-Version: 1.0
Content-Type: text/plain
This is the bug test email
EOF'
- Wait for RC to poll IMAP and create the room. Confirm in agent view
- room info must show Channel: Email not Channel: Livechat. If it shows Livechat, the room is not email-sourced and the bug will not trigger.
- Accept the conversation as an agent.
- Confirm SMTP is working by sending a test reply , verify if it arrives in MailDev UI at http://localhost:1080.
- Stop the SMTP server to simulate failure:
-
In the agent view, hover over the incoming email message then click Reply then type any text then hit Send.
-
Observe in the RC server logs:
ERROR (EmailInbox): Error sending Email reply
message: "connect ECONNREFUSED ::1:1025"
code: "ESOCKET"
- Also observe the
rocket.cat error message appearing in the room:
@agent something went wrong when replying email, sorry. Error: connect ECONNREFUSED
// Using Node.js mongo client
const msgs = await db.collection('rocketchat_message')
.find({ rid: '<roomId>' },{ projection: { msg: 1, blocks: 1, _updatedAt: 1 } }).toArray();
Expected behavior:
since the email was never delivered, the message state in DB should remain unchanged from its pre-send state. The agent should be able to safely retry.
Actual behavior:
The replied message has blocks written with To: / Subject: context despite SMTP failure. The DB record reflects a "sent" state that never happened:
Server Setup Information:
- Version of Rocket.Chat Server: 8.3.0-develop
- License Type: Community (dev build)
- Number of Users: 1 (local dev)
- Operating System: Linux Debian bookworm (x86_64)
- Deployment Method: Source / yarn dev (Meteor development server)
- Number of Running Instances: 1
- NodeJS Version: 22.16.0
- MongoDB Version: 7.0.16 (wiredTiger engine)
Client Setup Information
- Desktop App or Browser Version: Chrome 145.0.0.0
- Operating System: Linux
Additional Issues Found :
Dead Code Double if (!inbox) Check
File: EmailInbox_Outgoing.ts afterSaveMessage callback
The second if (!inbox) block (line 165) is unreachable the first block at line 155 already returns if inbox is false.
if (!inbox) {
await sendErrorReplyMessage(...);
return message; // always returns here
}
if (!inbox) { // DEAD CODE, never reached
return message;
}
Description:
In the file located at
apps/meteor/server/email-inbox/EmailInbox_Outgoing.ts. Before the email is confirmed sent. If SMTP fails, the message in the DB already shows the To: / Subject: context blocks as if the email was sent , but it was never delivered. So the message record in the database is updated to reflect a sent state regardless of whether the email was actually delivered.Steps to reproduce:
Prerequisites:
reproduction:
Drop a raw email into the IMAP mailbox to trigger onEmailReceived:
In the agent view, hover over the incoming email message then click Reply then type any text then hit Send.
Observe in the RC server logs:
rocket.caterror message appearing in the room:Expected behavior:
since the email was never delivered, the message state in DB should remain unchanged from its pre-send state. The agent should be able to safely retry.
Actual behavior:
The replied message has blocks written with To: / Subject: context despite SMTP failure. The DB record reflects a "sent" state that never happened:
Server Setup Information:
Client Setup Information
Additional Issues Found :
Dead Code Double
if (!inbox)CheckFile:
EmailInbox_Outgoing.tsafterSaveMessagecallbackThe second
if (!inbox)block (line 165) is unreachable the first block at line 155 already returns if inbox is false.