← 返回
未分类 中文

osascript-email

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.
使用 AppleScript 在macOS Mail.app 中自动发送纯文本邮件,无需 SMTP 凭据,适用于警报和报告,不适合批量或 HTML 邮件。
yumik20 yumik20 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 301
下载
💾 0
安装
1
版本
#latest

概述

osascript-email

Send email via Mail.app using AppleScript. No password or API key needed — Mail.app handles auth.

Prerequisites

  • macOS with Mail.app installed
  • At least one email account configured in Mail.app
  • Verify the sender address matches a configured Mail.app account
  • Authorization: This skill sends email silently from Mail.app. Only use with explicit user consent. Never use to send on behalf of a user without their knowledge.

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:

  • Double quotes inside subject/content must be escaped: \"
  • Backslashes must be doubled: \\
  • Newlines inside content: use \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_email

send_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

SymptomLikely causeFix
---------------------------
osascript: Mail got an errorMail.app not open or account not configuredOpen Mail.app, check accounts
Email lands in Draftssend m not reached (script errored before)Check escape characters
execution error: Mail got an error: Invalid recipientAddress typoVerify recipient address
Email sends but empty bodyNewline escape issue in content stringUse Python helper instead
returncode != 0 with no stderrosascript permission deniedGrant Automation permission: macOS Ventura+: System Settings → Privacy & Security → Automation; older macOS: System Preferences → Security & Privacy → Automation

Limitations

  • Plain text only (no HTML, no inline images)
  • Attachments possible but require additional AppleScript — see references/attachments.md
  • Rate: Mail.app will queue and send; not suitable for bulk sends (>10 emails)
  • Sender must be a configured Mail.app account — cannot spoof arbitrary addresses

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 19:51 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

office-efficiency

腾讯文档 TENCENT DOCS

u_b0de8114
腾讯文档(docs.qq.com)-在线云文档平台,是创建、编辑、管理文档的首选 skill。涉及"新建/创建/编辑/读取/查看/搜索文档"、"保存文件"、"云文档"、"腾讯文档"、"docs.qq.com"等操作,请优先使用本 skill
★ 183 📥 131,022
office-efficiency

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 479 📥 158,419
office-efficiency

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 937 📥 188,111