agentskit.js
ToolsIntegrations

email

Provider-agnostic SMTP send + IMAP fetch. BYO transport (nodemailer, imapflow, Resend, SES) — drivers stay out of the bundle.

import { email } from '@agentskit/tools'

const runtime = createRuntime({
  adapter,
  tools: [
    ...email({
      transport: myNodemailerAdapter,
      imap: myImapflowAdapter,
    }),
  ],
})

#Sub-tools

NamePurpose
emailSendSend a message via your EmailTransport
emailFetchList messages from a mailbox via your ImapClient

Bundled: email(config).

#Config

type EmailConfig = {
  transport?: EmailTransport          // for emailSend
  imap?: ImapClient                   // for emailFetch
  defaultFrom?: string
  maxFetch?: number                   // cap on emailFetch results (default 50)
}

type EmailTransport = {
  send: (msg: EmailSendMessage) => Promise<EmailSendResult>
}

type ImapClient = {
  fetch: (opts: ImapFetchOptions) => Promise<EmailMessage[]>
}

Heavy drivers (nodemailer, imapflow, mailparser) are not bundled. Wrap whatever you already use — a reference nodemailer/imapflow adapter lives in the AgentsKitOS triggers package.

#Example — outbound transactional

import { email } from '@agentskit/tools'
import nodemailer from 'nodemailer'

const transporter = nodemailer.createTransport({ host: 'smtp.example.com', port: 587, auth: { user, pass } })

const runtime = createRuntime({
  adapter,
  tools: [
    ...email({
      defaultFrom: 'bot@example.com',
      transport: { send: msg => transporter.sendMail(msg).then(r => ({ messageId: r.messageId, accepted: r.accepted, rejected: r.rejected })) },
    }),
  ],
})

await runtime.run('Email alex@x.com a one-line summary of yesterday\'s shipped PRs.')

#Example — inbound triage

const runtime = createRuntime({
  adapter,
  systemPrompt: 'Triage support email. Classify, draft a reply, never auto-send.',
  tools: [...email({ imap: imapAdapter })],
})

await runtime.run('Pull the last 20 unread messages from "support" and classify.')

#Safety

  • Default transport to a sandbox / dry-run mode in dev.
  • Hold a HITL gate before any outbound send to a user-supplied address.
  • Inbound HTML can carry prompt injection — strip/quote before passing to the model.

Explore nearby

✎ Edit this page on GitHub·Found a problem? Open an issue →·How to contribute →

On this page