X Tutup
Skip to content

fix: properly quote agent display names with special characters in email From header#13733

Open
realsamrat wants to merge 4 commits intochatwoot:developfrom
realsamrat:fix/quote-agent-name-in-email-from-header
Open

fix: properly quote agent display names with special characters in email From header#13733
realsamrat wants to merge 4 commits intochatwoot:developfrom
realsamrat:fix/quote-agent-name-in-email-from-header

Conversation

@realsamrat
Copy link

@realsamrat realsamrat commented Mar 7, 2026

Description

Fixes email delivery failures when an agent's display name contains punctuation characters such as periods, commas, or other RFC 5322 special characters (e.g., "Dr. Julio Menezes").

Per RFC 5322, display names in email headers that contain special characters must be properly quoted. Previously, Chatwoot constructed the From header by interpolating the agent name directly into the string without quoting, causing SMTP servers to reject or misparse the header.

This change uses Ruby's Mail::Address class to properly encode display names with special characters, ensuring RFC 5322 compliance.

Fixes #13667

Type of change

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

How Has This Been Tested?

  • Added specs to spec/mailers/conversation_reply_mailer_spec.rb that verify agent names containing periods and other RFC 5322 special characters are properly encoded in the From header
  • Verified the fix handles common punctuation: periods (Dr. Name), commas, quotes, angle brackets
  • Existing mailer tests continue to pass

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
  • 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

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 573479202a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

I18n.t('conversations.reply.email.header.professional_name', business_name: business_name, from_email: sender_email)
end
display_name = if @inbox.friendly?
"#{custom_sender_name} from #{business_name}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore localized sender name formatting

This change hardcodes the friendly display name as "#{custom_sender_name} from #{business_name}" instead of using the existing i18n keys, so all non-English locales (and any custom translation overrides) now emit an English From label and English word order. That is a regression for localized deployments because the previous implementation used conversations.reply.email.header.friendly_name / professional_name templates across locale files, and those translations are no longer applied in this mailer path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Email sending fails when agent name contains punctuation (e.g., "Dr. Julio Menezes")

1 participant

X Tutup