Skip to content

docs(smtp): document Params.FromHeader usage pattern#187

Merged
veverkap merged 2 commits into
mainfrom
copilot/add-doc-comment-params-fromheader
May 3, 2026
Merged

docs(smtp): document Params.FromHeader usage pattern#187
veverkap merged 2 commits into
mainfrom
copilot/add-doc-comment-params-fromheader

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 3, 2026

smtp.Params.FromHeader was undocumented in docs/smtp.md, leaving callers without guidance on which field to use as the From: message header vs. the SMTP envelope sender.

Changes

  • docs/smtp.md: Adds a Params fields section clarifying the From/FromHeader split — From is the bare address used internally by smtp.Send for the SMTP envelope; FromHeader is the RFC 5322-formatted string (properly quoted/MIME-encoded via mail.Address.String() when a display name is present) to set as the From: header in composed messages.
params, err := cfg.Validate()

msg := "From: " + params.FromHeader + "\r\n" +
    "To: recipient@example.com\r\n" +
    "Subject: Hello\r\n" +
    "\r\n" +
    "Message body.\r\n"

err = smtp.Send(ctx, params, "recipient@example.com", []byte(msg))

Greptile Summary

This docs-only PR adds a ## Params fields section to docs/smtp.md explaining the distinction between Params.From (bare SMTP envelope address) and Params.FromHeader (RFC 5322-formatted string for the From: header). The description and code example accurately reflect the implementation in smtp.Validate(), including the mail.Address.String() quoting/MIME-encoding behaviour and the fallback to the bare address when no display name is present.

Confidence Score: 5/5

Safe to merge — documentation-only change with no code modifications.

The PR adds only documentation. The new section accurately reflects the implementation in smtp.go (the From/FromHeader split, mail.Address.String() behaviour, and bare-address fallback are all correct). The previous thread concern about unchecked smtp.Send error has been addressed. No logic, security, or correctness issues found.

No files require special attention.

Important Files Changed

Filename Overview
docs/smtp.md Adds a Params fields section documenting the From/FromHeader split with a table and code example; content accurately reflects the implementation in smtp.go.

Sequence Diagram

sequenceDiagram
    participant App
    participant cfg as smtp.Config
    participant params as smtp.Params
    participant server as SMTP Server

    App->>cfg: LoadConfig()
    App->>cfg: Validate()
    cfg->>params: From = parsed.Address
    cfg->>params: FromHeader = parsed.Address (no display name) OR mail.Address.String() (with display name)
    cfg-->>App: Params

    App->>App: Build message using params.FromHeader as From: header
    App->>server: smtp.Send(ctx, params, to, msg) uses params.From for MAIL FROM envelope
Loading

Reviews (2): Last reviewed commit: "docs(smtp): fix RFC references and add e..." | Re-trigger Greptile

Comment thread docs/smtp.md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Documents how to correctly use smtp.Params.From vs smtp.Params.FromHeader so callers can distinguish the SMTP envelope sender (MAIL FROM) from the RFC 5322 From: header value when composing raw messages.

Changes:

  • Adds a Params fields section explaining the From/FromHeader split and when they differ.
  • Adds a short example showing params.FromHeader used in the From: header before calling smtp.Send.
Show a summary per file
File Description
docs/smtp.md Documents Params.FromHeader usage and provides an example for composing From: correctly.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread docs/smtp.md Outdated
- Clarify that display names are quoted per RFC 5322 and RFC 2047-encoded
  for non-ASCII characters, rather than the vague "MIME-encoded" wording
- Add error handling for smtp.Send call in the FromHeader usage example
@veverkap veverkap merged commit be3ad4c into main May 3, 2026
21 checks passed
@veverkap veverkap deleted the copilot/add-doc-comment-params-fromheader branch May 3, 2026 14:41
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.

3 participants