Mail Bridge
MailBridge — AI-initiated email sending with rate limiting
Allows the AI model to send emails via CALL:mail(to='...', subject='...', body='...') markers. Uses FORMCYCLE's mail API at runtime: obtains the system mail context via MailContextProvider.getSystemContext(), then sends through SimpleTextMail.
Security & Rate Limiting
Global cap: max GLOBAL_MAX_MAILS_PER_HOUR mails per hour across all sessions
Per-session cap: max SESSION_MAX_MAILS mails per streaming session
Recipient whitelist: only addresses matching allowedRecipientPattern are permitted
Subject and body are sanitized (no header injection)
Configuration
| Property | Format | Example |
|---|---|---|
AI_Mail_Enabled | true/false | true |
AI_Mail_AllowedRecipients | Regex pattern | .*@mycompany\.com |
AI_Mail_MaxPerHour | Integer | 10 |
AI_Mail_MaxPerSession | Integer | 3 |
AI_Mail_Disclaimer | Free text | AI-Generated |
Types
Result of an email send attempt.
Properties
Disclaimer text appended to every AI-sent email. Customise via AI_Mail_Disclaimer.
Regex pattern that recipient addresses must match. null = allow all.
Matches CALL:mail(to='...', subject='...', body='...') in model output (complete pattern).
Fallback pattern for truncated CALL:mail where the body was cut off by token limit. Captures to, subject, and whatever body text is available (even without closing quote/paren).
Whether the mail bridge is ready to send. If the system mail context is unavailable at runtime, sendMail will return an error.
Maximum mails per hour (global across all sessions).
Maximum mails per streaming session. Customise via AI_Mail_MaxPerSession.
Functions
Cleans an email address captured from model output. Strips emojis, icons (e.g. ✉), whitespace, and newlines.
Cleans up rate-limiting state for a finished session.
Formats a mail result into a text block suitable for injecting into the conversation.