diff --git a/src/tools/emails.ts b/src/tools/emails.ts index 3308ca7..f8bcfe0 100644 --- a/src/tools/emails.ts +++ b/src/tools/emails.ts @@ -149,10 +149,10 @@ export function addEmailTools( ...(replierEmailAddresses.length === 0 ? { replyTo: z - .array(z.email()) + .array(z.string()) .optional() .describe( - 'Optional email addresses for the email readers to reply to. You MUST ask the user for this parameter. Under no circumstance provide it yourself', + 'Optional email addresses for the email readers to reply to (e.g. "support@example.com" or "Support Team "). You MUST ask the user for this parameter. Under no circumstance provide it yourself', ), } : {}), @@ -1005,9 +1005,11 @@ export function addEmailTools( 'Sender email address. Falls back to the configured default sender if not provided.', ), replyTo: z - .array(z.email()) + .array(z.string()) .optional() - .describe('Reply-to email addresses'), + .describe( + 'Reply-to email addresses (e.g. "support@example.com" or "Support Team ")', + ), cc: z.array(z.email()).optional().describe('CC email addresses'), bcc: z .array(z.email()) diff --git a/tests/tools/emails.test.ts b/tests/tools/emails.test.ts index 94888dc..7974005 100644 --- a/tests/tools/emails.test.ts +++ b/tests/tools/emails.test.ts @@ -89,6 +89,70 @@ describe('send-email from address format', () => { }); }); +describe('replyTo address format', () => { + beforeEach(() => { + vi.clearAllMocks(); + send.mockResolvedValue({ + data: { id: 'email_1' }, + error: null, + }); + batchSend.mockResolvedValue({ + data: { data: [{ id: 'email_1' }] }, + error: null, + }); + }); + + it.each([ + 'support@example.com', + 'Support Team ', + ])('passes replyTo through send-email: %s', async (replyTo) => { + const client = await makeClient(); + const result = await client.callTool({ + name: 'send-email', + arguments: { + from: 'onboarding@resend.dev', + to: ['delivered@resend.dev'], + replyTo: [replyTo], + subject: 'hello', + text: 'world', + }, + }); + + expect(result.isError).toBeFalsy(); + expect(send).toHaveBeenCalledWith( + expect.objectContaining({ replyTo: [replyTo] }), + undefined, + ); + }); + + it.each([ + 'support@example.com', + 'Support Team ', + ])('passes replyTo through send-batch-emails: %s', async (replyTo) => { + const client = await makeClient(); + const result = await client.callTool({ + name: 'send-batch-emails', + arguments: { + emails: [ + { + from: 'onboarding@resend.dev', + to: ['delivered@resend.dev'], + replyTo: [replyTo], + subject: 'hello', + text: 'world', + }, + ], + }, + }); + + expect(result.isError).toBeFalsy(); + expect(batchSend).toHaveBeenCalledWith( + [expect.objectContaining({ replyTo: [replyTo] })], + undefined, + ); + }); +}); + describe('send-email idempotency key', () => { beforeEach(() => { vi.clearAllMocks();