send_smtp_email
Send emails via SMTP using 'send_smtp_email' by specifying the recipient, subject, and HTML body for automated email delivery in Sitecore Send workflows.
Instructions
Send an email using SMTP
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | HTML body of the email | |
| subject | Yes | Subject of the email | |
| to | Yes | Email address to send the email to |
Implementation Reference
- src/tools/smtp.ts:24-34 (handler)The execute function implementing the tool logic: sends email using SMTP client with provided to, subject, body, and returns success/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)Input schema using Zod defining required parameters: to (email), subject, body (HTML).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:6-37 (registration)The addSmptTools function that validates config, creates SMTP client, and registers the 'send_smtp_email' tool on the FastMCP server.export const addSmptTools: (server: FastMCP, config: SmtpConfig) => void = (server, config) => { if (!validateSmtpConfig(config)) { console.error("SMTP configuration is invalid. Please check your environment variables."); return false; } const client = createClient(config); 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." }] } } }); return true; }
- lib/smtp.ts:4-12 (helper)Helper function to create Nodemailer SMTP transport client from configuration.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 } });