send_email
Send emails through iCloud Mail to recipients with subject and text or HTML content. Use this tool to compose and deliver messages directly from your workflow.
Instructions
Send an email through iCloud Mail
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| html | No | HTML email body | |
| subject | Yes | Email subject | |
| text | No | Plain text email body | |
| to | Yes | Recipient email address(es) |
Implementation Reference
- src/lib/icloud-mail-client.ts:355-381 (handler)Core handler function that executes the email sending logic using nodemailer Transporter via iCloud SMTP.async sendEmail(options: SendEmailOptions): Promise<{ messageId: string }> { const mailOptions: nodemailer.SendMailOptions = { from: this.config.email, to: options.to, subject: options.subject, }; if (options.text) { mailOptions.text = options.text; } if (options.html) { mailOptions.html = options.html; } if (options.attachments) { mailOptions.attachments = options.attachments.map((att) => ({ filename: att.filename, path: att.path, content: att.content, contentType: att.contentType, })); } const info = await this.transporter.sendMail(mailOptions); return { messageId: info.messageId }; }
- src/index.ts:419-442 (handler)MCP server request handler that processes 'send_email' tool calls and delegates to iCloudMailClient.sendEmail.case 'send_email': { if (!mailClient) { throw new McpError( ErrorCode.InvalidRequest, 'iCloud Mail not configured. Please set ICLOUD_EMAIL and ICLOUD_APP_PASSWORD environment variables.' ); } const result = await mailClient.sendEmail({ to: args?.to as string | string[], subject: args?.subject as string, text: args?.text as string, html: args?.html as string, }); return { content: [ { type: 'text', text: `Email sent successfully. Message ID: ${result.messageId}`, }, ], }; }
- src/index.ts:81-109 (registration)Registers the 'send_email' tool in the MCP ListTools response with name, description, and input schema.{ name: 'send_email', description: 'Send an email through iCloud Mail', inputSchema: { type: 'object', properties: { to: { oneOf: [ { type: 'string' }, { type: 'array', items: { type: 'string' } }, ], description: 'Recipient email address(es)', }, subject: { type: 'string', description: 'Email subject', }, text: { type: 'string', description: 'Plain text email body', }, html: { type: 'string', description: 'HTML email body', }, }, required: ['to', 'subject'], }, },
- src/types/config.ts:28-39 (schema)TypeScript interface defining the input parameters for the sendEmail function.export interface SendEmailOptions { to: string | string[]; subject: string; text?: string; html?: string; attachments?: Array<{ filename: string; path?: string; content?: Buffer; contentType?: string; }>; }