← All tools

Communication

Email

Send transactional email from agents.

email

Overview

Sends an email from the agent. Use it to notify someone when a long-running task finishes, to deliver a generated report, or to flag an issue that needs a human's attention.

How it works

Sends an email through the SMTP server configured via Spring Mail. Accepts 'to', 'subject', and 'body' (plus optional 'cc', 'bcc', 'attachments') and returns a confirmation with the message ID. Uses whatever SMTP credentials your Spring Boot application provides.

Example

When a user asks:

Email the quarterly report to our investors list.

the agent calls the tool:

email(to="investors@example.com", subject="Q4 2026 Report", body="…")

and gets back: confirmation of successful delivery with a message ID.

Configuration

Set these before calling the tool. Values marked required must be present or the tool call will fail.

SMTP_HOST required

SMTP server host (also exposed via spring.mail.host).

SMTP_USERNAME required

SMTP auth username (spring.mail.username).

SMTP_PASSWORD required

SMTP auth password (spring.mail.password).

spring.mail.port optional

SMTP port (typically 587 or 465).

Use it in a workflow

Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.

YAML DSL

# notification.yaml
name: notification-crew
process: SEQUENTIAL

agents:
  - id: notifier
    role: Notification Agent
    goal: Deliver crew output to stakeholders via email
    tools:
      - email

tasks:
  - id: notification-task
    agent: notifier
    description: Email the quarterly report to investors@example.com with subject 'Q4 2026 Report'.

Java

import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.common.EmailTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;

@Autowired ChatClient chatClient;
@Autowired EmailTool emailTool;

Agent notifier = Agent.builder()
    .role("Notification Agent")
    .goal("Deliver crew output to stakeholders via email")
    .chatClient(chatClient)
    .tool(emailTool)
    .build();

Task notifierTask = Task.builder()
    .description("Email the quarterly report to investors@example.com with subject 'Q4 2026 Report'.")
    .agent(notifier)
    .build();

SwarmOutput result = Swarm.builder()
    .agent(notifier)
    .task(notifierTask)
    .process(ProcessType.SEQUENTIAL)
    .build()
    .kickoff();

What it's good for

Real scenarios where agents put this tool to work.

Notification agents for completed reports
Alerting on monitoring thresholds
Sending generated executive summaries to stakeholders
Daily digest crews

Source

Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/common/EmailTool.java in the swarm-ai repository.

Open email on GitHub →