Skip to content

feat(gmail): add --body-html-file for sending HTML emails from files #575

@toruvieI

Description

@toruvieI

Summary

Please add a --body-html-file option to gog gmail send, analogous to the existing plain-text --body-file option.

Current behavior

gog gmail send currently supports:

--body-file=STRING   Body file path (plain text; '-' for stdin)
--body-html=STRING   Body (HTML; optional)

So when sending an HTML email from a prepared file, the practical workaround is something like:

gog gmail send \
  --to recipient@example.com \
  --subject "Subject" \
  --body-file tmp/email.txt \
  --body-html "$(cat tmp/email.html)"

This works for small HTML bodies, but it is awkward and can fail for larger HTML documents because the entire HTML body has to fit into the shell command argv/env limits. It also makes command previews noisy and harder to review.

Proposed behavior

Add:

--body-html-file=STRING   HTML body file path; '-' for stdin if feasible

Example:

gog gmail send \
  --to recipient@example.com \
  --subject "Subject" \
  --body-file tmp/email.txt \
  --body-html-file tmp/email.html \
  --json --no-input

Why this helps

  • Avoids argv length limits for larger HTML emails.
  • Matches the ergonomics of --body-file for plain text.
  • Makes scripted HTML email sending cleaner and easier to audit.
  • Avoids shell-specific command substitution edge cases and huge command previews.

Implementation sketch

This should be a narrow CLI addition:

  1. Add a bodyHTMLFile / body-html-file flag to the Gmail send command.
  2. Read the file content using the same file/stdin helper pattern as --body-file, if one already exists.
  3. Reject using both --body-html and --body-html-file together.
  4. Feed the loaded string into the same MIME/HTML body path currently used by --body-html.
  5. Add a small CLI test covering HTML-from-file and the mutual-exclusion error.

@steipete if this UX is acceptable, say the word and I can prepare a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions