send-email
Send emails via MailPace MCP Server using JSON input for to, from, subject, and attachments. Simplify email delivery for transactional purposes with structured data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| attachments | No | ||
| bcc | No | ||
| cc | No | ||
| from | Yes | ||
| htmlbody | No | ||
| inreplyto | No | ||
| list_unsubscribe | No | ||
| references | No | ||
| replyto | No | ||
| subject | No | ||
| tags | No | ||
| textbody | No | ||
| to | Yes |
Implementation Reference
- index.ts:47-89 (handler)The handler function for the 'send-email' tool. It validates that either textbody or htmlbody is provided, sends the email using the MailPace client, and returns a structured success or error response.async (params, _extra) => { try { if (!params.textbody && !params.htmlbody) { return { content: [{ type: "text", text: "Either text or html content must be provided" }], isError: true }; } // Send the email const result = await client.sendEmail(params); return { content: [ { type: "text", text: JSON.stringify({ success: true, message: "Email sent successfully", data: { messageId: result.id, status: result.status } }, null, 2) } ] }; } catch (error: any) { console.error(`Error sending email: ${error.message}`); return { content: [ { type: "text", text: JSON.stringify({ success: false, message: "Failed to send email", error: error.message }, null, 2) } ], isError: true }; } }
- index.ts:28-46 (schema)Zod schema defining the input parameters for the 'send-email' tool, including from, to, subject, body options, CC/BCC, attachments, and tags.from: z.string().email(), to: z.string(), subject: z.string().optional(), htmlbody: z.string().optional(), textbody: z.string().optional(), cc: z.string().optional(), bcc: z.string().optional(), replyto: z.string().optional(), inreplyto: z.string().optional(), references: z.string().optional(), list_unsubscribe: z.string().optional(), attachments: z.array(z.object({ name: z.string(), content: z.string(), content_type: z.string(), cid: z.string().optional() })).optional(), tags: z.union([z.string(), z.array(z.string())]).optional() },
- index.ts:25-90 (registration)Registration of the 'send-email' tool on the MCP server using server.tool(), including name, input schema, and handler function.server.tool( "send-email", { from: z.string().email(), to: z.string(), subject: z.string().optional(), htmlbody: z.string().optional(), textbody: z.string().optional(), cc: z.string().optional(), bcc: z.string().optional(), replyto: z.string().optional(), inreplyto: z.string().optional(), references: z.string().optional(), list_unsubscribe: z.string().optional(), attachments: z.array(z.object({ name: z.string(), content: z.string(), content_type: z.string(), cid: z.string().optional() })).optional(), tags: z.union([z.string(), z.array(z.string())]).optional() }, async (params, _extra) => { try { if (!params.textbody && !params.htmlbody) { return { content: [{ type: "text", text: "Either text or html content must be provided" }], isError: true }; } // Send the email const result = await client.sendEmail(params); return { content: [ { type: "text", text: JSON.stringify({ success: true, message: "Email sent successfully", data: { messageId: result.id, status: result.status } }, null, 2) } ] }; } catch (error: any) { console.error(`Error sending email: ${error.message}`); return { content: [ { type: "text", text: JSON.stringify({ success: false, message: "Failed to send email", error: error.message }, null, 2) } ], isError: true }; } } );