Skip to content

Support optional display names on from, to, cc, and bcc for send-email and sandbox#72

Merged
mklocek merged 1 commit into
mainfrom
fix-66
Mar 31, 2026
Merged

Support optional display names on from, to, cc, and bcc for send-email and sandbox#72
mklocek merged 1 commit into
mainfrom
fix-66

Conversation

@mklocek

@mklocek mklocek commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Motivation

#66

Changes

  • Support optional display names on from, to, cc, and bcc for send-email and sandbox

Summary by CodeRabbit

  • New Features
    • Email address fields now support optional display names for sender and recipients, enabling richer contact information and improved email clarity.
    • Sender and recipient fields accept flexible input formats: plain email strings or objects with email and optional name properties.

…l and sandbox

Shared MailtrapAddressParam schema and helpers; sandbox keeps comma-separated
to string for plain addresses and adds array form for named recipients.

Closes #66.
@coderabbitai

coderabbitai Bot commented Mar 30, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dac00ef0-356c-443b-981a-553783420545

📥 Commits

Reviewing files that changed from the base of the PR and between d6201c4 and d2c81ad.

📒 Files selected for processing (9)
  • src/tools/sandbox/__tests__/sendSandboxEmail.test.ts
  • src/tools/sandbox/schemas/sendSandboxEmail.ts
  • src/tools/sandbox/sendSandboxEmail.ts
  • src/tools/schemas/mailtrapAddressParam.ts
  • src/tools/sendEmail/__tests__/sendEmail.test.ts
  • src/tools/sendEmail/schema.ts
  • src/tools/sendEmail/sendEmail.ts
  • src/types/mailtrap.ts
  • src/utils/mailtrapAddresses.ts

📝 Walkthrough

Walkthrough

This PR centralizes email address handling by introducing shared utilities and schemas. It enables sendEmail and sendSandboxEmail to accept addresses as either plain email strings or objects containing email with optional display names, with new utility functions normalizing these inputs across both tools.

Changes

Cohort / File(s) Summary
Shared Utilities & Schemas
src/tools/schemas/mailtrapAddressParam.ts, src/utils/mailtrapAddresses.ts
New modules providing a shared schema (mailtrapAddressParamSchema) for email address inputs and utility functions (toMailtrapAddress, buildFromAddress, normalizeAddressList, normalizeToRecipients, parseSandboxTo) to normalize address data across tools.
Type Definitions
src/types/mailtrap.ts
Added MailtrapAddressParam type union (string | { email, name? }) and updated SendMailToolRequest and SendSandboxEmailRequest interfaces to use this type for from, to, cc, and bcc fields.
Send Email Tool
src/tools/sendEmail/schema.ts, src/tools/sendEmail/sendEmail.ts
Schema now uses mailtrapAddressParamSchema for address fields; implementation refactored to use buildFromAddress, normalizeToRecipients, and normalizeAddressList utilities, removing inline normalization logic.
Send Sandbox Email Tool
src/tools/sandbox/schemas/sendSandboxEmail.ts, src/tools/sandbox/sendSandboxEmail.ts
Schema updated to support richer address inputs via mailtrapAddressParamSchema with oneOf for to field (comma-separated string or array); implementation delegated to buildFromAddress, parseSandboxTo, and normalizeAddressList utilities.
Tests
src/tools/sendEmail/__tests__/sendEmail.test.ts, src/tools/sandbox/__tests__/sendSandboxEmail.test.ts
Added comprehensive test cases verifying that both tools correctly handle and preserve address objects with display names in from, to, cc, and bcc fields, and that success messages include only email addresses.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Integrate sandbox #32: Related updates to sandbox email functionality, sendSandboxEmail implementation, and associated schema and test changes.

Suggested reviewers

  • IgorDobryn
  • piobeny
  • VladimirTaytor

Poem

🐰 With ears held high and nose a-twitch,
We bundled addresses, made the switch!
Names and emails, now combined with care,
Shared schemas keep the code so fair! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes motivation (issue #66) and changes, but is missing the 'How to test' section with test steps and the 'Images and GIFs' comparison table required by the template. Add 'How to test' section with specific test steps and 'Images and GIFs' section showing before/after comparisons to match the repository template.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding support for optional display names on email address fields across send-email and sandbox endpoints.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-66

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@@ -0,0 +1,31 @@
/**
* JSON Schema fragment: email string or `{ email, name? }` for Mailtrap Address fields.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Supporting just string for backward compatibility.

@mklocek mklocek merged commit 142be61 into main Mar 31, 2026
2 checks passed
@mklocek mklocek deleted the fix-66 branch March 31, 2026 12:34
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