Skip to main content
Glama

send-email

Send emails from ClaudePost after confirming recipient details, subject, and content. Use this tool to dispatch verified email communications securely.

Instructions

CONFIRMATION STEP: Actually send the email after user confirms the details. Before calling this, first show the email details to the user for confirmation. Required fields: recipients (to), subject, and content. Optional: CC recipients.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesList of recipient email addresses (confirmed)
subjectYesConfirmed email subject
contentYesConfirmed email content
ccNoList of CC recipient email addresses (optional, confirmed)

Implementation Reference

  • Dispatch handler logic within @server.call_tool() that validates arguments and invokes send_email_async for the send-email tool.
    if name == "send-email":
        to_addresses = arguments.get("to", [])
        subject = arguments.get("subject", "")
        content = arguments.get("content", "")
        cc_addresses = arguments.get("cc", [])
        
        if not to_addresses:
            return [types.TextContent(
                type="text",
                text="At least one recipient email address is required."
            )]
        
        try:
            logging.info("Attempting to send email")
            logging.info(f"To: {to_addresses}")
            logging.info(f"Subject: {subject}")
            logging.info(f"CC: {cc_addresses}")
            
            async with asyncio.timeout(SEARCH_TIMEOUT):
                await send_email_async(to_addresses, subject, content, cc_addresses)
                return [types.TextContent(
                    type="text",
                    text="Email sent successfully! Check email_client.log for detailed logs."
                )]
        except asyncio.TimeoutError:
            logging.error("Operation timed out while sending email")
            return [types.TextContent(
                type="text",
                text="Operation timed out while sending email."
            )]
        except Exception as e:
            error_msg = str(e)
            logging.error(f"Failed to send email: {error_msg}")
            return [types.TextContent(
                type="text",
                text=f"Failed to send email: {error_msg}\n\nPlease check:\n1. Email and password are correct in .env\n2. SMTP settings are correct\n3. Less secure app access is enabled (for Gmail)\n4. Using App Password if 2FA is enabled"
            )]
  • Core helper function that constructs and sends the email using SMTP with configuration from EMAIL_CONFIG.
    async def send_email_async(
        to_addresses: list[str],
        subject: str,
        content: str,
        cc_addresses: list[str] | None = None
    ) -> None:
        """Asynchronously send an email."""
        try:
            # Create message
            msg = MIMEMultipart()
            msg['From'] = EMAIL_CONFIG["email"]
            msg['To'] = ', '.join(to_addresses)
            if cc_addresses:
                msg['Cc'] = ', '.join(cc_addresses)
            msg['Subject'] = subject
            
            # Add body
            msg.attach(MIMEText(content, 'plain', 'utf-8'))
            
            # Connect to SMTP server and send email
            def send_sync():
                with smtplib.SMTP(EMAIL_CONFIG["smtp_server"], EMAIL_CONFIG["smtp_port"]) as server:
                    server.set_debuglevel(1)  # Enable debug output
                    logging.debug(f"Connecting to {EMAIL_CONFIG['smtp_server']}:{EMAIL_CONFIG['smtp_port']}")
                    
                    # Start TLS
                    logging.debug("Starting TLS")
                    server.starttls()
                    
                    # Login
                    logging.debug(f"Logging in as {EMAIL_CONFIG['email']}")
                    server.login(EMAIL_CONFIG["email"], EMAIL_CONFIG["password"])
                    
                    # Send email
                    all_recipients = to_addresses + (cc_addresses or [])
                    logging.debug(f"Sending email to: {all_recipients}")
                    result = server.send_message(msg, EMAIL_CONFIG["email"], all_recipients)
                    
                    if result:
                        # send_message returns a dict of failed recipients
                        raise Exception(f"Failed to send to some recipients: {result}")
                    
                    logging.debug("Email sent successfully")
            
            # Run the synchronous send function in the executor
            loop = asyncio.get_event_loop()
            await loop.run_in_executor(None, send_sync)
            
        except Exception as e:
            logging.error(f"Error in send_email_async: {str(e)}")
            raise
  • Registers the send-email tool in the @server.list_tools() handler, including its description and input schema.
    types.Tool(
        name="send-email",
        description="CONFIRMATION STEP: Actually send the email after user confirms the details. Before calling this, first show the email details to the user for confirmation. Required fields: recipients (to), subject, and content. Optional: CC recipients.",
        inputSchema={
            "type": "object",
            "properties": {
                "to": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "List of recipient email addresses (confirmed)",
                },
                "subject": {
                    "type": "string",
                    "description": "Confirmed email subject",
                },
                "content": {
                    "type": "string",
                    "description": "Confirmed email content",
                },
                "cc": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "List of CC recipient email addresses (optional, confirmed)",
                },
            },
            "required": ["to", "subject", "content"],
        },
    ),
  • JSON Schema defining the input parameters for the send-email tool: required to, subject, content; optional cc.
        "type": "object",
        "properties": {
            "to": {
                "type": "array",
                "items": {"type": "string"},
                "description": "List of recipient email addresses (confirmed)",
            },
            "subject": {
                "type": "string",
                "description": "Confirmed email subject",
            },
            "content": {
                "type": "string",
                "description": "Confirmed email content",
            },
            "cc": {
                "type": "array",
                "items": {"type": "string"},
                "description": "List of CC recipient email addresses (optional, confirmed)",
            },
        },
        "required": ["to", "subject", "content"],
    },

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other 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/meyannis/mcpemail'

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