Skip to content

Email Tools

Read, send, and manage emails programmatically

Astonish provides 8 email tools for full inbox management. These tools require IMAP/SMTP configuration.

Set up email with the interactive CLI:

Terminal window
astonish channels setup email

Or configure through Studio Settings > Channels. For manual configuration, add the following to config.yaml:

channels:
email:
enabled: true
imap_server: "imap.gmail.com:993"
smtp_server: "smtp.gmail.com:587"
address: "agent@example.com"
username: "agent@example.com"
password: "app-password" # Stored in credential store after setup

For Gmail, use an App Password rather than your account password. After initial setup, the password is moved to the encrypted credential store and removed from the config file.

List emails with optional filtering.

ParameterTypeRequiredDescription
folderstringNoIMAP folder (default: INBOX)
unreadboolNoOnly unread messages
fromstringNoFilter by sender (substring match)
subjectstringNoFilter by subject (substring match)
sincestringNoMessages after this date (ISO 8601)
limitintNoMax results (default: 20)

Read the full content of an email by its ID. Returns the body, headers, links, and any extracted verification links.

ParameterTypeRequiredDescription
idstringYesMessage ID from email_list

Search emails with advanced filters.

ParameterTypeRequiredDescription
querystringNoFree-text search
fromstringNoFilter by sender
tostringNoFilter by recipient
subjectstringNoFilter by subject
sincestringNoDate range start (ISO 8601)
beforestringNoDate range end (ISO 8601)
has_attachmentboolNoOnly messages with attachments
folderstringNoIMAP folder (default: INBOX)
limitintNoMax results (default: 20)

Compose and send a new email.

ParameterTypeRequiredDescription
tostring[]YesRecipient addresses
ccstring[]NoCC addresses
subjectstringYesSubject line
bodystringYesPlain text body
htmlstringNoOptional HTML body
reply_tostringNoReply-To address

Reply to an existing email, preserving the thread.

ParameterTypeRequiredDescription
idstringYesMessage ID to reply to
bodystringYesReply body
htmlstringNoOptional HTML reply body
reply_allboolNoReply to all recipients (default: false)

Mark one or more emails as read or unread.

ParameterTypeRequiredDescription
idsstring[]YesMessage IDs
unreadboolNoMark as unread instead (default: false)

Delete one or more emails.

ParameterTypeRequiredDescription
idsstring[]YesMessage IDs
permanentboolNoSkip trash, delete permanently (default: false)

Wait for a matching email to arrive. Polls the inbox until a match is found or the timeout is reached. Useful for registration and verification flows.

ParameterTypeRequiredDescription
fromstringNoSender substring match
subjectstringNoSubject substring match
timeout_secondsintNoHow long to wait (default: 120, max: 300)
poll_interval_secondsintNoCheck interval in seconds (default: 5, min: 3)

Common Workflow: Automated Signup Verification

Section titled “Common Workflow: Automated Signup Verification”

Email tools pair well with browser automation for end-to-end signup flows:

  1. Submit the registration form using browser tools (browser_navigate, browser_type, browser_click).
  2. Wait for the verification email with email_wait, matching on the expected sender or subject.
  3. Read the email with email_read to extract the verification link.
  4. Complete verification by navigating to the link with browser_navigate.