fix: filter Content-Transfer-Encoding from custom headers#158
Merged
drish merged 1 commit intoresend:mainfrom Feb 27, 2026
Merged
Conversation
The Mail gem includes Content-Transfer-Encoding as a header field, and its `unparsed_value` can return the Ruby constant name (e.g. `Mail::Encodings::SevenBit`) instead of the actual encoding string `7bit`. Since this header was not in IGNORED_HEADERS, it was passed through to the Resend API as a custom header, resulting in malformed Content-Transfer-Encoding values in outgoing emails. This causes email providers like Yahoo to flag messages as spam. The Resend API already handles Content-Transfer-Encoding via Amazon SES, so this header should be filtered like content-type and mime-version. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
IGNORED_HEADERSlist filters MIME headers that the Resend API / AmazonSES handles automatically (
content-type,mime-version, etc.), butcontent-transfer-encodingwas missing.The Mail gem includes this as a header field on every message. When
headers_values()reads itsunparsed_value, some versions of the Mail gemreturn the Ruby constant name (e.g.
Mail::Encodings::SevenBit) instead ofthe actual encoding string
7bit. This gets passed through to the Resend APIas a custom header and appears verbatim in outgoing emails:
Email providers like Yahoo flag this malformed header and route messages to spam.
Fix
Add
content-transfer-encodingtoIGNORED_HEADERS, consistent withcontent-typeandmime-versionwhich are already filtered.Test plan
content-transfer-encodingis inIGNORED_HEADERSand not passed through as a custom header
Summary by cubic
Filters Content-Transfer-Encoding from custom headers to prevent malformed values (e.g., Mail::Encodings::SevenBit) from being sent. Aligns with other auto-handled MIME headers and helps avoid spam routing.
Written for commit 217d3a5. Summary will update on new commits.