Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/gmail-default-sender.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@googleworkspace/cli": minor
---

feat(gmail): auto-populate From header with display name from send-as settings

Fetch the user's send-as identities to set the From header with a display name in all mail helpers (+send, +reply, +reply-all, +forward), matching Gmail web client behavior. Also enriches bare `--from` emails with their configured display name.
7 changes: 7 additions & 0 deletions .changeset/gmail-self-reply-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@googleworkspace/cli": patch
---

fix(gmail): handle reply-all to own message correctly

Reply-all to a message you sent no longer errors with "No To recipient remains." The original To recipients are now used as reply targets, matching Gmail web client behavior.
12 changes: 9 additions & 3 deletions src/auth_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,15 @@ async fn handle_login(args: &[String]) -> Result<(), GwsError> {
..Default::default()
};

// Ensure openid + email scopes are always present so we can identify the user
// via the userinfo endpoint after login.
let identity_scopes = ["openid", "https://www.googleapis.com/auth/userinfo.email"];
// Ensure openid + email + profile scopes are always present so we can
// identify the user via the userinfo endpoint after login, and so the
// Gmail helpers can fall back to the People API to populate the From
// display name when the send-as identity lacks one (Workspace accounts).
let identity_scopes = [
"openid",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
];
for s in &identity_scopes {
if !scopes.iter().any(|existing| existing == s) {
scopes.push(s.to_string());
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/gmail/forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(super) async fn handle_forward(
doc: &crate::discovery::RestDescription,
matches: &ArgMatches,
) -> Result<(), GwsError> {
let config = parse_forward_args(matches)?;
let mut config = parse_forward_args(matches)?;

let dry_run = matches.get_flag("dry-run");

Expand All @@ -34,6 +34,7 @@ pub(super) async fn handle_forward(
.map_err(|e| GwsError::Auth(format!("Gmail auth failed: {e}")))?;
let client = crate::client::build_client()?;
let orig = fetch_message_metadata(&client, &t, &config.message_id).await?;
config.from = resolve_sender(&client, &t, config.from.as_deref()).await?;
(orig, Some(t))
};

Expand Down
Loading
Loading