osascript-email
by @yumik20
Send automated plain-text emails on macOS via Mail.app using AppleScript without SMTP credentials, suitable for alerts and reports, not bulk or HTML emails.
clawhub install osascript-emailπ About This Skill
name: osascript-email description: Send emails on macOS via AppleScript (osascript) using Mail.app β no SMTP credentials, passwords, or API keys required. Use when: sending automated emails from macOS, sending standup reports or alerts via email, emailing from a cron job or agent, or when other email tools (sendmail, himalaya, SMTP) are unavailable or unconfigured. Requires Mail.app to be installed and configured with at least one account. NOT for: bulk email sends; HTML email; email with large attachments; non-macOS environments.
osascript-email
Send email via Mail.app using AppleScript. No password or API key needed β Mail.app handles auth.
Prerequisites
Quick send (exec)
Use exec to run an inline osascript command. The script below is the canonical pattern β copy it exactly, then substitute values.
osascript << 'APPLESCRIPT'
tell application "Mail"
set m to make new outgoing message with properties {subject:"YOUR SUBJECT", content:"YOUR BODY", visible:false}
tell m
make new to recipient with properties {address:"recipient@example.com"}
make new to recipient with properties {address:"cc@example.com"}
end tell
send m
end tell
return "sent"
APPLESCRIPT
Escaping rules:
\"\\\n (AppleScript treats literal newlines in the string as content)Python helper (for agent scripts)
Use when sending email from a Python cron script or agent workflow. Copy the function from scripts/send_email.py β do not rewrite it.
from scripts.send_email import send_emailsend_email(
subject="Daily Report β 2026-01-01",
body="Here is the summary...",
to="primary@example.com",
cc="secondary@example.com", # optional
sender="your-mail-app-account@icloud.com" # must match Mail.app account
)
See scripts/send_email.py for the full implementation.
Multi-recipient
Add additional make new to recipient lines inside the tell m block:
make new to recipient with properties {address:"a@example.com"}
make new to recipient with properties {address:"b@example.com"}
Troubleshooting
| Symptom | Likely cause | Fix |
|---------|-------------|-----|
| osascript: Mail got an error | Mail.app not open or account not configured | Open Mail.app, check accounts |
| Email lands in Drafts | send m not reached (script errored before) | Check escape characters |
| execution error: Mail got an error: Invalid recipient | Address typo | Verify recipient address |
| Email sends but empty body | Newline escape issue in content string | Use Python helper instead |
| returncode != 0 with no stderr | osascript permission denied | Grant Automation permission: macOS Ventura+: System Settings β Privacy & Security β Automation; older macOS: System Preferences β Security & Privacy β Automation |
Limitations
references/attachments.mdβοΈ Configuration
π Tips & Best Practices
| Symptom | Likely cause | Fix |
|---------|-------------|-----|
| osascript: Mail got an error | Mail.app not open or account not configured | Open Mail.app, check accounts |
| Email lands in Drafts | send m not reached (script errored before) | Check escape characters |
| execution error: Mail got an error: Invalid recipient | Address typo | Verify recipient address |
| Email sends but empty body | Newline escape issue in content string | Use Python helper instead |
| returncode != 0 with no stderr | osascript permission denied | Grant Automation permission: macOS Ventura+: System Settings β Privacy & Security β Automation; older macOS: System Preferences β Security & Privacy β Automation |