Skip to main content
Glama

test_email_connection

Test SMTP and IMAP connections to verify email server functionality for sending and receiving messages.

Instructions

测试邮箱服务器连接

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
testTypeNo测试类型:smtp(发送)、imap(接收)或both(全部)

Implementation Reference

  • The testConnection method implements the core logic for testing email server connections. It verifies SMTP using nodemailer's transporter.verify() and tests IMAP by attempting to connect and open the INBOX. Supports testing 'smtp', 'imap', or 'both' based on input.
    async testConnection(args = {}) { const { testType = 'both' } = args; let results = []; try { // 测试SMTP连接 if (testType === 'smtp' || testType === 'both') { try { const transporter = this.createSMTPTransporter(); await transporter.verify(); results.push('✅ SMTP服务器连接测试成功!'); } catch (error) { results.push(`❌ SMTP连接测试失败: ${error.message}`); } } // 测试IMAP连接 if (testType === 'imap' || testType === 'both') { try { await new Promise((resolve, reject) => { const imap = this.createIMAPConnection(); imap.once('ready', () => { imap.end(); resolve(); }); imap.once('error', (err) => { reject(err); }); imap.connect(); }); results.push('✅ IMAP服务器连接测试成功!'); } catch (error) { results.push(`❌ IMAP连接测试失败: ${error.message}`); } } return { content: [ { type: 'text', text: results.join('\n') } ] }; } catch (error) { return { content: [ { type: 'text', text: `❌ 测试失败: ${error.message}` } ] }; } }
  • The input schema for the test_email_connection tool, defining an optional testType parameter with enum values 'smtp', 'imap', or 'both'.
    { name: 'test_email_connection', description: '测试邮箱服务器连接', inputSchema: { type: 'object', properties: { testType: { type: 'string', enum: ['smtp', 'imap', 'both'], description: '测试类型:smtp(发送)、imap(接收)或both(全部)' } }, required: [] } }
  • index.js:358-359 (registration)
    The switch case in the CallToolRequestSchema handler that registers and dispatches calls to the test_email_connection tool by invoking the testConnection method.
    case 'test_email_connection': return await this.testConnection(args);

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