Skip to main content
Glama

setup_email_account

Automatically configures email accounts by identifying the provider type and setting up server details, ensuring ready-to-use email integration for various providers.

Instructions

设置邮箱账号(自动识别邮箱类型并配置服务器)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailYes邮箱地址(如 user@qq.com)
passwordYes邮箱密码或授权码
providerNo邮箱提供商(可选,不填写则自动识别)

Implementation Reference

  • The core handler function implementing the 'setup_email_account' tool logic. It configures the email account by setting environment variables for credentials, detecting the provider, applying server configurations from EMAIL_CONFIGS, and returning a formatted success message with details.
    async setupEmailAccount(args) { const { email, password, provider } = args; // 设置用户名和密码 process.env.EMAIL_USER = email; process.env.EMAIL_PASSWORD = password; let detectedProvider = provider; let config; try { // 如果没有指定提供商,则自动检测 if (!detectedProvider) { detectedProvider = this.detectEmailProvider(email); if (!detectedProvider) { return { content: [{ type: 'text', text: `❌ 无法识别邮箱类型: ${email}\n\n支持的邮箱类型请使用 list_supported_providers 查看,或手动指定 provider 参数。` }] }; } } // 自动配置服务器设置 config = this.autoConfigureByProvider(detectedProvider); let result = `✅ 邮箱账号设置成功!\n\n`; result += `📧 邮箱地址: ${email}\n`; result += `🏢 邮箱提供商: ${config.name}\n`; result += `📤 SMTP服务器: ${config.smtp.host}:${config.smtp.port} (SSL: ${config.smtp.secure})\n`; result += `📥 接收协议: ${config.usePOP3 ? 'POP3' : 'IMAP'}\n`; if (config.usePOP3) { result += `📥 POP3服务器: ${config.pop3.host}:${config.pop3.port} (SSL: ${config.pop3.secure})\n`; } else { result += `📥 IMAP服务器: ${config.imap.host}:${config.imap.port} (SSL: ${config.imap.secure})\n`; } result += `\n💡 提示: 配置已自动完成,您现在可以使用邮件功能了!`; return { content: [{ type: 'text', text: result }] }; } catch (error) { return { content: [{ type: 'text', text: `❌ 邮箱设置失败: ${error.message}` }] }; } }
  • The tool schema definition including name, description, and inputSchema for validation, provided in the ListTools response.
    name: 'setup_email_account', description: '设置邮箱账号(自动识别邮箱类型并配置服务器)', inputSchema: { type: 'object', properties: { email: { type: 'string', description: '邮箱地址(如 user@qq.com)' }, password: { type: 'string', description: '邮箱密码或授权码' }, provider: { type: 'string', enum: ['qq', '163', 'gmail', 'outlook', 'exmail', 'aliyun', 'sina', 'sohu'], // 暂时注释掉: 'netease-enterprise' description: '邮箱提供商(可选,不填写则自动识别)' } }, required: ['email', 'password'] } },
  • index.js:352-353 (registration)
    The dispatch registration in the CallToolRequestHandler switch statement that routes calls to the setupEmailAccount handler.
    case 'setup_email_account': return await this.setupEmailAccount(args);
  • Helper method to detect the email provider from the email domain or manual specification, used by the handler.
    detectEmailProvider(email, manualType = null) { // 优先使用手动指定的邮箱类型 if (manualType && EMAIL_CONFIGS[manualType]) { console.log(`使用手动指定的邮箱类型: ${manualType} (${EMAIL_CONFIGS[manualType].name})`); return manualType; } // 如果没有手动指定,则根据域名自动检测 const domain = email.split('@')[1]?.toLowerCase(); if (!domain) return null; for (const [provider, config] of Object.entries(EMAIL_CONFIGS)) { if (config.domains.includes(domain)) { console.log(`自动检测到邮箱类型: ${provider} (${config.name})`); return provider; } } console.log(`未能识别邮箱类型,域名: ${domain}`); return null; }
  • Helper method that configures environment variables for SMTP, IMAP, and POP3 based on the detected provider, called by the handler.
    autoConfigureByProvider(provider) { const config = EMAIL_CONFIGS[provider]; if (!config) { throw new Error(`不支持的邮箱类型: ${provider}`); } // 设置SMTP配置 process.env.EMAIL_SMTP_HOST = config.smtp.host; process.env.EMAIL_SMTP_PORT = config.smtp.port.toString(); process.env.EMAIL_SMTP_SECURE = config.smtp.secure.toString(); // 设置IMAP配置 process.env.EMAIL_IMAP_HOST = config.imap.host; process.env.EMAIL_IMAP_PORT = config.imap.port.toString(); process.env.EMAIL_IMAP_SECURE = config.imap.secure.toString(); // 设置POP3配置 process.env.EMAIL_POP3_HOST = config.pop3.host; process.env.EMAIL_POP3_PORT = config.pop3.port.toString(); process.env.EMAIL_POP3_SECURE = config.pop3.secure.toString(); // 设置协议偏好 process.env.EMAIL_USE_POP3 = config.usePOP3.toString(); return config; }

Other Tools

Related Tools

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