send_email
Send transactional emails through GetMailer MCP Server. Deliver automated messages to recipients with HTML or text content, CC/BCC options, and template support.
Instructions
Send a transactional email via GetMailer
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from | Yes | Sender email address (must be from a verified domain) | |
| to | Yes | Recipient email address(es) | |
| subject | Yes | Email subject line | |
| html | No | HTML content of the email | |
| text | No | Plain text content of the email | |
| cc | No | CC recipients (optional) | |
| bcc | No | BCC recipients (optional) | |
| replyTo | No | Reply-to address (optional) | |
| templateId | No | Template ID to use instead of html/text (optional) | |
| variables | No | Template variables as key-value pairs (optional) |
Implementation Reference
- src/index.ts:352-368 (handler)Handler for the 'send_email' tool: Posts the input arguments to the GetMailer API /api/emails endpoint using the apiRequest helper and returns the JSON result as text content.case 'send_email': { const result = await apiRequest<{ email: unknown; suppressed?: string[] }>( '/api/emails', { method: 'POST', body: JSON.stringify(args), } ); return { content: [ { type: 'text' as const, text: JSON.stringify(result, null, 2), }, ], }; }
- src/index.ts:66-118 (registration)Registration of the 'send_email' tool in the ListToolsRequestHandler, including name, description, and detailed input schema.{ name: 'send_email', description: 'Send a transactional email via GetMailer', inputSchema: { type: 'object' as const, properties: { from: { type: 'string', description: 'Sender email address (must be from a verified domain)', }, to: { type: 'array', items: { type: 'string' }, description: 'Recipient email address(es)', }, subject: { type: 'string', description: 'Email subject line', }, html: { type: 'string', description: 'HTML content of the email', }, text: { type: 'string', description: 'Plain text content of the email', }, cc: { type: 'array', items: { type: 'string' }, description: 'CC recipients (optional)', }, bcc: { type: 'array', items: { type: 'string' }, description: 'BCC recipients (optional)', }, replyTo: { type: 'string', description: 'Reply-to address (optional)', }, templateId: { type: 'string', description: 'Template ID to use instead of html/text (optional)', }, variables: { type: 'object', description: 'Template variables as key-value pairs (optional)', }, }, required: ['from', 'to', 'subject'], }, },
- src/index.ts:21-48 (helper)Shared helper function apiRequest used by the send_email handler (and others) to make authenticated HTTP requests to the GetMailer API.async function apiRequest<T>( endpoint: string, options: RequestInit = {} ): Promise<T> { const url = `${API_URL}${endpoint}`; const response = await fetch(url, { ...options, headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${API_KEY}`, ...options.headers, }, }); if (!response.ok) { let errorMessage = response.statusText; try { const errorData = await response.json(); errorMessage = errorData.error || errorData.message || errorMessage; } catch { // Ignore } throw new Error(`API Error: ${errorMessage}`); } return response.json(); }