chore: Add a condition to handle bounced email (#11873)

Add bounced emails to the conversation thread.
Fix Gmail bounce detection by checking the X-Failed-Recipients header.

Currently, bounced emails are rejected as auto-replies, which causes
support agents to miss important delivery failure context. This PR
ensures bounced messages are correctly added to the thread, preserving
visibility for the support team.
This commit is contained in:
Pranav
2025-08-01 02:13:46 -07:00
committed by GitHub
parent c98c255ed0
commit 5ab913f7b5
4 changed files with 139 additions and 6 deletions

View File

@@ -115,6 +115,14 @@ RSpec.describe Imap::ImapMailbox do
end
end
context 'when the email is bounced' do
let!(:bounced_mail) { create_inbound_email_from_fixture('bounced_gmail.eml') }
it 'processes the bounced email' do
expect { class_instance.process(bounced_mail.mail, channel) }.to change(Message, :count)
end
end
context 'when a reply for existing email conversation' do
let(:prev_conversation) { create(:conversation, account: account, inbox: channel.inbox, assignee: agent) }
let(:reply_mail) do