Skip to main content
Glama

send_email

Send emails programmatically using TurboSMTP. Define recipients, subject, and content to deliver messages directly from your application. Optional HTML and sender address flexibility included.

Instructions

Send an email via TurboSMTP

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromNoSender email address (optional, uses configured one if not specified)
htmlNoHTML content of the email (optional)
subjectYesEmail subject
textYesText content of the email
toYesList of recipient email addresses

Implementation Reference

  • Main handler for executing the send_email tool. Validates input parameters, checks email formats, calls EmailService.sendEmail, and formats the success response.
    async handleSendEmail(args) {
      const { to, subject, text, html, from } = args;
    
      // Input validation
      if (!to || !Array.isArray(to) || to.length === 0) {
        throw new Error('The "to" field must be a non-empty array of email addresses');
      }
    
      if (!subject || typeof subject !== 'string') {
        throw new Error('The "subject" field is required and must be a string');
      }
    
      if (!text || typeof text !== 'string') {
        throw new Error('The "text" field is required and must be a string');
      }
    
      // Email validation
      const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
      for (const email of to) {
        if (!emailRegex.test(email)) {
          throw new Error(`Invalid email address: ${email}`);
        }
      }
    
      if (from && !emailRegex.test(from)) {
        throw new Error(`Invalid sender email address: ${from}`);
      }
    
      try {
        const result = await EmailService.sendEmail({
          to,
          subject,
          text,
          html,
          from
        });
    
        return {
          content: [
            {
              type: 'text',
              text: `✅ Email sent successfully!\n\nRecipients: ${to.join(', ')}\nSubject: ${subject}\n\nDetails: ${JSON.stringify(result.data, null, 2)}`
            }
          ]
        };
      } catch (error) {
        throw new Error(`Error sending email: ${error.message}`);
      }
    }
  • Input schema defining the parameters for the send_email tool, including types, descriptions, and required fields.
    inputSchema: {
      type: 'object',
      properties: {
        to: {
          type: 'array',
          items: { type: 'string' },
          description: 'List of recipient email addresses'
        },
        subject: {
          type: 'string',
          description: 'Email subject'
        },
        text: {
          type: 'string',
          description: 'Text content of the email'
        },
        html: {
          type: 'string',
          description: 'HTML content of the email (optional)'
        },
        from: {
          type: 'string',
          description: 'Sender email address (optional, uses configured one if not specified)'
        }
      },
      required: ['to', 'subject', 'text']
    }
  • Registration of the send_email tool in the ListToolsRequestSchema handler, including name, description, and schema.
    {
      name: 'send_email',
      description: 'Send an email via TurboSMTP',
      inputSchema: {
        type: 'object',
        properties: {
          to: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of recipient email addresses'
          },
          subject: {
            type: 'string',
            description: 'Email subject'
          },
          text: {
            type: 'string',
            description: 'Text content of the email'
          },
          html: {
            type: 'string',
            description: 'HTML content of the email (optional)'
          },
          from: {
            type: 'string',
            description: 'Sender email address (optional, uses configured one if not specified)'
          }
        },
        required: ['to', 'subject', 'text']
      }
    },
  • Core helper function in EmailService that constructs the payload and sends the email via TurboSMTP API using axios.
    async sendEmail({to, subject, text, html, from}) {
        try {
            const payload = {
                to: (Array.isArray(to) ? to : [to]).join(","),
                subject,
                content: text || '',
                html_content: html || '',
                from: from || process.env.TURBOSMTP_FROM_EMAIL
            };
    
            const response = await axios.post(
                `${this.sendApiUrl}/mail/send`,
                payload,
                {headers: this.headers}
            );
    
            return {
                success: true,
                message: 'Email sent successfully',
                data: response.data
            };
        } catch (error) {
            console.error('Error sending email:', error.response?.data || error.message);
            throw new Error(
                error.response?.data?.message ||
                'Error sending email: ' + error.message
            );
        }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Send an email' implies a write operation, it doesn't mention authentication requirements, rate limits, error handling, or what happens upon success (e.g., confirmation, message ID). This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence that directly states the tool's function without any unnecessary words. It's front-loaded and wastes no space, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, or behavioral nuances. Given the complexity of email sending (which involves delivery status, potential failures, etc.), more context would be needed for an agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, providing clear documentation for all 5 parameters. The tool description adds no additional parameter information beyond what's already in the schema, so it meets the baseline expectation without adding extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Send an email') and specifies the service ('via TurboSMTP'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools (which are analytics-related), though this isn't necessary since they serve completely different functions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or any contextual constraints. It simply states what the tool does without indicating appropriate scenarios or limitations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/debba/turbosmtp-mcp-server'

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