Skip to content

Commit ef3eb91

Browse files
turianclaude
andcommitted
Add --from flag to email.draft-reply, remove naive auto-detection
Codex correctly identified that using original.to[0] as the from address is problematic - it fails for group emails, CC'd recipients, etc. Since we can't access Identity/get (requires submission capability which we intentionally avoid for safety), we: 1. Remove the naive auto-detection 2. Add --from flag to let users explicitly specify the from address 3. Default to server's account default when --from not provided Users should use --from when replying to emails received on non-default addresses (e.g., --from "joseph@noc0.dev"). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 48aca4f commit ef3eb91

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/fastmail_cli/jmapc.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,8 @@ def handle_email_draft_reply(args: argparse.Namespace) -> Tuple[int, Dict[str, A
431431
else:
432432
references = original.message_id
433433

434-
# Set from address to the address that received the original email
435-
# This ensures replies come from the correct identity (e.g., joseph@noc0.dev not turian@fastmail.com)
436-
from_addr = original.to[0] if original.to else None
434+
# Parse from address if provided, otherwise let server use account default
435+
from_addr = parse_email_addresses(args.mail_from) if args.mail_from else None
437436

438437
# Find the Drafts mailbox
439438
drafts_mailbox_id = find_drafts_mailbox_id(client, account_id)
@@ -451,7 +450,7 @@ def handle_email_draft_reply(args: argparse.Namespace) -> Tuple[int, Dict[str, A
451450
email = Email(
452451
mailbox_ids={drafts_mailbox_id: True},
453452
keywords={"$draft": True},
454-
mail_from=[from_addr] if from_addr else None,
453+
mail_from=from_addr,
455454
to=to_addrs,
456455
cc=cc_addrs,
457456
subject=subject,
@@ -829,6 +828,7 @@ def COMMAND_SPECS() -> Dict[str, Dict[str, Any]]:
829828
{"name": "reply_all", "type": "flag", "required": False},
830829
{"name": "to", "type": "string", "required": False},
831830
{"name": "subject", "type": "string", "required": False},
831+
{"name": "from", "type": "string", "required": False},
832832
],
833833
},
834834
"email.changes": {
@@ -948,6 +948,7 @@ def build_parser() -> argparse.ArgumentParser:
948948
er.add_argument("--reply-all", action="store_true", help="Reply to all recipients")
949949
er.add_argument("--to", help="Override recipient(s)")
950950
er.add_argument("--subject", help="Override subject")
951+
er.add_argument("--from", dest="mail_from", help="From address (default: account default)")
951952

952953
ech = sub.add_parser("email.changes", help="Email/changes")
953954
add_connection_opts(ech)

0 commit comments

Comments
 (0)