fix: validate support_email format and handle parse errors in mailer (#13958)

## Description

ConversationReplyMailer#parse_email calls
Mail::Address.new(email_string).address without error handling. When an
account's support_email contains a non-email string (e.g., "Smith
Smith"), the mail gem raises Mail::Field::IncompleteParseError, crashing
conversation transcript emails.

This has caused 1,056 errors on Sentry (EXTERNAL-CHATINC-JX) since Feb
25, all from a single account that has a name stored in the
support_email field instead of a valid email address.

Closes
https://linear.app/chatwoot/issue/CW-6687/mailfieldincompleteparseerror-mailaddresslist-can-not-parse-orsmith

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)


## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Vishnu Narayanan <iamwishnu@gmail.com>
This commit is contained in:
Tanmay Deep Sharma
2026-04-13 19:06:06 +07:00
committed by GitHub
parent 0592cccca9
commit 722e68eecb
7 changed files with 102 additions and 52 deletions

View File

@@ -5,6 +5,7 @@ class ConversationReplyMailer < ApplicationMailer
include ConversationReplyMailerHelper
include ReferencesHeaderBuilder
include EmailAddressParseable
default from: ENV.fetch('MAILER_SENDER_EMAIL', 'Chatwoot <accounts@chatwoot.com>')
layout :choose_layout
@@ -139,10 +140,6 @@ class ConversationReplyMailer < ApplicationMailer
sender_name(@channel.email)
end
def parse_email(email_string)
Mail::Address.new(email_string).address
end
def inbox_from_email_address
return @inbox.email_address if @inbox.email_address