-
Notifications
You must be signed in to change notification settings - Fork 497
Description
Description
When sending or creating drafts with --body or --body-file, the CLI hard-wraps plain text at ~72 characters (RFC 2822 line folding) before sending to the Gmail API. This silently destroys paragraph formatting in sent emails.
Steps to Reproduce
- Create a file with a single long paragraph (e.g., 200+ chars on one line):
echo "This is a long paragraph that should reflow naturally in the recipient's email client but instead gets chopped into narrow lines by the CLI before it even reaches Gmail." > /tmp/test.txt - Send or create a draft:
gog gmail drafts create --to "test@example.com" --subject "Test" --body-file /tmp/test.txt -a me@example.com --client myclient - Send the draft from Gmail
Expected Behavior
The paragraph renders as a single reflowing block in the recipient's email client.
Actual Behavior
The paragraph is chopped into ~72-char lines with hard \r\n breaks:
This is a long paragraph that should reflow naturally in the
recipient's email client but instead gets chopped into narrow lines
by the CLI before it even reaches Gmail.
This is invisible in Gmail's compose/draft view (which reflows text while editing) but appears as broken formatting once the email is actually sent and viewed by recipients.
Root Cause
The Go MIME library used to construct the text/plain MIME part applies RFC 2822 line folding at ~72 characters. While this was historically needed for SMTP transport, modern email clients and the Gmail API handle long lines fine. The wrapping is applied after reading the input file, so even perfectly formatted single-line paragraphs get wrapped.
Suggested Fix
Option A (preferred): Stop hard-wrapping text/plain bodies by default. The Gmail API and modern email infrastructure do not require 72-char folding for message bodies.
Option B: Add a --no-wrap flag to disable line folding when the user wants to preserve their original formatting.
Option C (minimum): Document this behavior so users know --body content will be reformatted, and recommend --body-html as a workaround.
Workaround
Use --body-html with <p> tags instead of --body / --body-file. HTML bodies are not subject to line folding.
Environment
- gogcli v0.12.0 (Homebrew, macOS)
- Sending via Gmail API