Skip to main content
Glama

send_forward

Forward emails to new recipients with optional comments and HTML formatting using the Mail MCP Server's email management capabilities.

Instructions

Forward an email to another recipient

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesForward recipient addresses
subjectYesForward subject (usually with Fwd:)
original_folderNoFolder of original email (optional, if fetching original)
original_message_idNoMessage ID of email to forward (optional, if fetching original)
body_textNoAdditional comment for forward
body_htmlNoAdditional HTML comment for forward

Implementation Reference

  • The send_forward function implements the logic for forwarding an email, including constructing the forward email body with original message details and sending it via SMTP.
    def send_forward(
        client,
        to: list[str],
        subject: str | None,
        original_message: Message | None = None,
        original_email_data: dict[str, Any] | None = None,
        body_text: str | None = None,
        body_html: str | None = None,
        from_addr: str | None = None,
    ) -> SendResult:
        """
        转发邮件
    
        Args:
            client: SMTP 客户端对象
            to: 转发目标收件人列表
            subject: 主题 (如果为 None 会自动添加 Fwd:)
            original_message: 原邮件消息对象 (Message 类型)
            original_email_data: 原邮件数据 (dict 类型,从 IMAPClient.get_email 返回)
            body_text: 附言 (纯文本)
            body_html: 附言 (HTML)
            from_addr: 发件人地址
    
        Returns:
            SendResult: 发送结果
        """
        # 验证参数
        if not to:
            return SendResult(success=False, error="收件人列表不能为空")
    
        # 验证邮箱地址
        for addr in to:
            if not validate_email_address(addr):
                return SendResult(success=False, error=f"无效的收件人地址: {addr}")
    
        try:
            # 获取发件人地址
            if not from_addr:
                if hasattr(client, "config") and hasattr(client.config, "user"):
                    from_addr = client.config.user
                else:
                    return SendResult(success=False, error="缺少发件人地址")
    
            # 处理 original_email_data (dict 格式)
            if original_email_data and isinstance(original_email_data, dict):
                original_subject = original_email_data.get("subject", "")
                original_from = original_email_data.get("from", "N/A")
                original_to = original_email_data.get("to", "N/A")
                original_date = original_email_data.get("date", "N/A")
                original_body = original_email_data.get("body_text", "") or original_email_data.get(
                    "body", ""
                )
            elif original_message:
                # 处理 Message 对象
                original_subject = original_message.get("Subject", "")
                original_from = original_message.get("From", "N/A")
                original_to = original_message.get("To", "N/A")
                original_date = original_message.get("Date", "N/A")
                # 获取邮件内容
                original_body = ""
                if hasattr(original_message, "walk"):
                    for part in original_message.walk():
                        if part.get_content_type() == "text/plain":
                            try:
                                original_body = part.get_payload(decode=True).decode("utf-8")
                            except Exception:
                                pass
                            break
            else:
                # 没有原邮件数据
                original_subject = ""
                original_from = "N/A"
                original_to = "N/A"
                original_date = "N/A"
                original_body = ""
    
            if subject is None:
                if original_subject and not original_subject.startswith("Fwd:"):
                    subject = f"Fwd: {original_subject}"
                elif original_subject:
                    subject = original_subject
                else:
                    subject = "Fwd: (no subject)"
    
            # 构建转发邮件正文
            forward_text = ""
            if body_text:
                forward_text = body_text + "\n\n"
    
            # 添加原邮件信息
            forward_text += "---------- 转发邮件 ----------\n"
            forward_text += f"From: {original_from}\n"
            forward_text += f"To: {original_to}\n"
            forward_text += f"Subject: {original_subject}\n"
            forward_text += f"Date: {original_date}\n"
            forward_text += "\n"
    
            # 添加原邮件内容
            if original_body:
                forward_text += original_body
    
            # 构建邮件
            message = build_email_message(
                sender=from_addr,
                to=to,
                subject=subject,
                body_text=forward_text,
                body_html=body_html,
            )
    
            # 生成 Message-ID
            message_id = make_msgid()
            message["Message-ID"] = message_id
    
            # 发送邮件
            smtp = _get_smtp_client(client)
            smtp.send_message(message, from_addr=from_addr, to_addrs=to)
    
            return SendResult(
                success=True,
                message_id=message_id,
            )
    
        except smtplib.SMTPException as e:
            return SendResult(success=False, error=f"SMTP 错误: {str(e)}")
        except Exception as e:
            return SendResult(success=False, error=f"转发失败: {str(e)}")
Behavior2/5

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

No annotations provided, yet description fails to disclose critical behavioral traits: whether the original email is included automatically, if the operation sends immediately or creates a draft, side effects on the original message, or error handling when original references are missing.

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

Conciseness4/5

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

Single sentence with no redundant words or fluff. Front-loaded with the core action. However, extreme brevity contributes to informational gaps; efficiency is high but appropriateness of size for complexity is questionable.

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?

Inadequate for a 6-parameter mutation tool with no annotations and no output schema. Missing: sibling differentiation, behavioral side effects, return value description, and clarification of the optional original message reference workflow implied by the schema.

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?

Schema has 100% description coverage, documenting all 6 parameters including the 'Additional comment' nature of body fields. Description adds no parameter semantics beyond schema, which is acceptable given high coverage, meeting the baseline.

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

Purpose3/5

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

States the basic action (forward email to recipient) but lacks specificity regarding scope or differentiation from siblings like send_email or send_reply. Does not clarify what distinguishes a 'forward' from a reply or new message in this context.

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?

Provides no guidance on when to use this tool versus send_reply or send_email. Does not explain the workflow for optional parameters (original_message_id/folder) or when the tool can be used without referencing an original email.

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

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/AdJIa/mail-mcp-server'

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