send_smtp_email
Send emails via SMTP protocol to deliver messages with specified recipients, subjects, and HTML content.
Instructions
Send an email using SMTP
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Email address to send the email to | |
| subject | Yes | Subject of the email | |
| body | Yes | HTML body of the email |
Implementation Reference
- src/tools/smtp.ts:24-34 (handler)The execute handler for the send_smtp_email tool, which sends the email using the SMTP client and returns success or failure message.execute: async ({ to, subject, body }) => { const res = await client.sendMail({ from: config.from, to, subject, html: body, }); return { content: [{ type: "text", text: res.accepted.length > 0 ? "Email sent successfully." : "Email sending failed." }] } }
- src/tools/smtp.ts:15-19 (schema)Zod schema defining the input parameters for the send_smtp_email tool: to, subject, body.parameters: z.object({ to: z.string().email().describe("Email address to send the email to"), subject: z.string().describe("Subject of the email"), body: z.string().describe("HTML body of the email"), }),
- src/tools/smtp.ts:12-35 (registration)Registration of the send_smtp_email tool via server.addTool, including name, description, schema, annotations, and inline handler.server.addTool({ name: "send_smtp_email", description: "Send an email using SMTP", parameters: z.object({ to: z.string().email().describe("Email address to send the email to"), subject: z.string().describe("Subject of the email"), body: z.string().describe("HTML body of the email"), }), annotations: { title: "Send SMTP Email", openWorldHint: true, }, execute: async ({ to, subject, body }) => { const res = await client.sendMail({ from: config.from, to, subject, html: body, }); return { content: [{ type: "text", text: res.accepted.length > 0 ? "Email sent successfully." : "Email sending failed." }] } } });
- lib/smtp.ts:4-12 (helper)Helper function to create the Nodemailer SMTP transport client used by the tool handler.export const createClient = (smtpConfig: SmtpConfig) => nodemailer.createTransport({ host: smtpConfig.host, port: smtpConfig.port, secure: smtpConfig.secure, auth: { user: smtpConfig.auth.user, pass: smtpConfig.auth.pass } });
- src/tools/index.ts:7-7 (registration)Calls addSmptTools to register SMTP tools, invoked from the main tools aggregator.addSmptTools(server, config.smtp);