Skip to main content
Glama

get_email_content

Retrieve detailed content from specific emails by providing their unique identifier to access full message information.

Instructions

获取指定邮件的详细内容

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYes邮件唯一标识符

Implementation Reference

  • The core handler function that connects to IMAP, fetches the email by UID, parses it using simpleParser, and formats the content including headers, text/HTML body, and attachments list.
    async getEmailContent(args) { const { uid } = args; return new Promise((resolve, reject) => { const imap = this.createIMAPConnection(); imap.once('ready', () => { imap.openBox('INBOX', true, (err, box) => { if (err) { imap.end(); return reject(err); } // 获取指定UID的邮件 const fetch = imap.fetch([uid], { bodies: '', struct: true }); fetch.on('message', (msg, seqno) => { msg.on('body', (stream, info) => { simpleParser(stream, (err, parsed) => { imap.end(); if (err) { return reject(err); } let content = `📧 邮件详情 (UID: ${uid})\n`; content += `────────────────────────────────\n`; content += `📅 日期: ${parsed.date || '未知'}\n`; content += `👤 发件人: ${parsed.from?.text || '未知'}\n`; content += `👥 收件人: ${parsed.to?.text || '未知'}\n`; if (parsed.cc) { content += `📋 抄送: ${parsed.cc.text}\n`; } content += `📝 主题: ${parsed.subject || '(无主题)'}\n`; content += `────────────────────────────────\n`; // 邮件内容 if (parsed.text) { content += `📄 文本内容:\n${parsed.text}\n`; } if (parsed.html && parsed.html !== parsed.text) { content += `🌐 HTML内容:\n${parsed.html}\n`; } // 附件信息 if (parsed.attachments && parsed.attachments.length > 0) { content += `📎 附件列表:\n`; parsed.attachments.forEach((att, index) => { content += ` ${index + 1}. ${att.filename || '未命名'} (${att.size || 0} bytes)\n`; }); } resolve({ content: [{ type: 'text', text: content }] }); }); }); }); fetch.once('error', (err) => { imap.end(); reject(err); }); }); }); imap.once('error', (err) => { reject(err); }); imap.connect(); }); }
  • The tool registration object defining the name, description, and input schema (requiring 'uid' string parameter).
    name: 'get_email_content', description: '获取指定邮件的详细内容', inputSchema: { type: 'object', properties: { uid: { type: 'string', description: '邮件唯一标识符' } }, required: ['uid'] }
  • index.js:341-373 (registration)
    The request handler registration with switch case that dispatches 'get_email_content' calls to the handler function.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { switch (name) { case 'send_email': return await this.sendEmail(args); case 'get_recent_emails': return await this.getRecentEmails(args); case 'get_email_content': return await this.getEmailContent(args); case 'setup_email_account': return await this.setupEmailAccount(args); case 'list_supported_providers': return await this.listSupportedProviders(args); case 'configure_email_server': return await this.configureEmailServer(args); case 'test_email_connection': return await this.testConnection(args); default: throw new Error(`未知的工具: ${name}`); } } catch (error) { return { content: [ { type: 'text', text: `错误: ${error.message}` } ] }; } });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TimeCyber/email-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server