send_email
Send emails programmatically using SendGrid's API to deliver messages with plain text, HTML, or dynamic templates to verified recipients.
Instructions
Send an email using SendGrid
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Recipient email address | |
| subject | Yes | Email subject line | |
| text | Yes | Plain text content of the email | |
| html | No | HTML content of the email (optional) | |
| from | Yes | Sender email address (must be verified with SendGrid) | |
| template_id | No | SendGrid template ID (optional) | |
| dynamic_template_data | No | Dynamic data for template variables (optional) |
Implementation Reference
- src/services/sendgrid.ts:15-25 (handler)Core implementation of the send_email tool: sends email using SendGrid's sgMail.send API.async sendEmail(params: { to: string; from: string; subject: string; text: string; html?: string; template_id?: string; dynamic_template_data?: Record<string, any>; }) { return await sgMail.send(params); }
- src/tools/index.ts:34-67 (schema)Input schema definition for the send_email tool, specifying parameters and validation.inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient email address' }, subject: { type: 'string', description: 'Email subject line' }, text: { type: 'string', description: 'Plain text content of the email' }, html: { type: 'string', description: 'HTML content of the email (optional)' }, from: { type: 'string', description: 'Sender email address (must be verified with SendGrid)' }, template_id: { type: 'string', description: 'SendGrid template ID (optional)' }, dynamic_template_data: { type: 'object', description: 'Dynamic data for template variables (optional)' } }, required: ['to', 'subject', 'text', 'from'] }
- src/tools/index.ts:31-68 (registration)Registration of the send_email tool in the getToolDefinitions array.{ name: 'send_email', description: 'Send an email using SendGrid', inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient email address' }, subject: { type: 'string', description: 'Email subject line' }, text: { type: 'string', description: 'Plain text content of the email' }, html: { type: 'string', description: 'HTML content of the email (optional)' }, from: { type: 'string', description: 'Sender email address (must be verified with SendGrid)' }, template_id: { type: 'string', description: 'SendGrid template ID (optional)' }, dynamic_template_data: { type: 'object', description: 'Dynamic data for template variables (optional)' } }, required: ['to', 'subject', 'text', 'from'] } },
- src/tools/index.ts:395-397 (handler)Tool invocation handler in handleToolCall that delegates to SendGridService.sendEmail.case 'send_email': await service.sendEmail(args); return { content: [{ type: 'text', text: `Email sent successfully to ${args.to}` }] };