Skip to content

fix(gmail): omit From when the default send-as identity is a nameless primary - #950

Open
pingavibe wants to merge 1 commit into
googleworkspace:mainfrom
pingavibe:fix/gmail-from-nameless-primary
Open

pingavibe wants to merge 1 commit into
googleworkspace:mainfrom
pingavibe:fix/gmail-from-nameless-primary

Conversation

@pingavibe

Copy link
Copy Markdown

Description

Fixes #644 for the common case.

Every mail helper (+send, +reply, +reply-all, +forward, and --draft) resolves its From header in resolve_sender. When no --from is given, it lists settings.sendAs and uses the default identity. For an ordinary account, Gmail returns that identity as the primary address with an empty displayName, because the name comes from the Google account or directory profile. resolve_sender then wrote an explicit bare From: <user@example.com>. Gmail delivers an explicit From exactly as written, so recipients see only the address. The People API fallback only helps when the profile scope is granted and the People API is enabled in the GCP project, which is why #644 still reproduces with the scope granted (see also #684).

With this change, when the default identity is the primary address and has no display name, resolve_sender returns no From. Gmail then stamps the account's own Name <address>, as the Gmail web client does. No extra scope or API is needed, and the People API request is no longer made on this path.

before: sendAs {isPrimary, isDefault, displayName: ""} -> From: <user@gmail.com>
after:  sendAs {isPrimary, isDefault, displayName: ""} -> (no From) -> Gmail stamps "Name <user@gmail.com>"

What stays the same:

  • An identity with a display name still yields From: Name <address>.
  • A nameless default that is not the primary keeps its explicit address. The message is still sent from that alias, and reply-all still excludes it.
  • An explicit --from is unchanged. Bare addresses are still enriched from sendAs.
  • The sending address never changes. The new branch only fires when the default is the primary, and Gmail sends from the primary when From is absent.
  • A sendAs entry without isPrimary is treated as non-primary, so it keeps the previous behavior.

Verified against real Gmail: a message sent through users.messages.send with no From header was delivered as From: <Account Name> <address>.

Dry Run Output: not applicable (no request-schema change).

Checklist:

  • My code follows the AGENTS.md guidelines (no generated google-* crates).
  • I have run cargo fmt --all to format the code perfectly.
  • I have run cargo clippy -- -D warnings and resolved all warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have provided a Changeset file (e.g. via pnpx changeset) to document my changes.

… primary

Gmail returns an empty send-as displayName for a primary address whose
name comes from the account. resolve_sender wrote that identity as an
explicit bare From, which Gmail delivers verbatim, so recipients saw only
the address. Omit the header in that case so Gmail stamps the account's
own "Name <address>", as its web client does. Nameless non-primary
aliases and explicit --from are unchanged.

Fixes googleworkspace#644
@changeset-bot

changeset-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f329855

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-cla

google-cla Bot commented Oct 2, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@googleworkspace-bot googleworkspace-bot added the area: core Core CLI parsing, commands, error handling, utilities label Oct 2, 2026
@pingavibe

Copy link
Copy Markdown
Author

@googleworkspace-bot recheck

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

Labels

area: core Core CLI parsing, commands, error handling, utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gmail +send shows "grant profile scope" tip and sends with null From name even when profile scope is granted

2 participants