Skip to main content

sendAgentEmail()

Sends an email via the PhoneClaw agent email service. Useful for notifications, alerts, and automation reports.
string
required
Recipient email address.
string
required
Email subject line.
string
required
Email body content. Supports plain text only.
void
Sends email asynchronously. Success/failure is spoken via TTS.

Basic Usage

Practical Examples

Implementation Details

Source Location

MainActivity.kt:738

Email Service

The function sends emails through a backend API:
  • HTTP POST to configured server endpoint
  • Requires security key authentication
  • 30-second timeout for requests
  • Asynchronous execution (non-blocking)
Email delivery is asynchronous. The function returns immediately while the email is sent in the background.

Configuration

The email server endpoint URL and security key are configured in the MainActivity source code. You must update these values to use your own email service.
To configure the email service:
  1. Set up a backend email API endpoint
  2. Update apiUrl in MainActivity.kt:742
  3. Update securityKey in MainActivity.kt:741
  4. Rebuild the app

Backend API Format

Your email endpoint should accept:
And return:

Complete Examples

Automation Report System

Multi-Recipient Notifications

Scheduled Reports

Best Practices

Include context in subjects for easy filtering and prioritization.
Always include when and where events occurred.
Rate-limit notifications to prevent flooding inboxes.
Reserve emails for important events. Use speech or logs for routine updates.

Limitations

  • Requires configured backend email service
  • 30-second timeout per request
  • No support for HTML emails (plain text only)
  • No attachment support
  • No delivery confirmation
  • Rate limiting depends on backend service

Troubleshooting

Email Not Sending

Check these common issues:
  1. Backend not configured: Verify apiUrl points to valid endpoint
  2. Security key mismatch: Ensure key matches backend
  3. Network issues: Check device internet connection
  4. Backend errors: Check backend logs

Testing

  • speakText() - Alternative notification method via TTS
  • schedule() - Schedule automated email reports
  • delay() - Add delays between multiple emails