我想知道当我的Mac重新启动时,是否有办法通过Command Line或AppleScript服务自动发送电子邮件给自己?谢谢你的建议。
我想知道当我的Mac重新启动时,是否有办法通过Command Line或AppleScript服务自动发送电子邮件给自己?谢谢你的建议。
Answers:
我知道这样做最简单的方法是使用以下格式在crontab中添加一行:
@reboot /path/to/your/script
该脚本可以使用mail命令调用date命令。
osascript 可能对此有所帮助,但如果您需要更多详细信息,请提出新问题。 
                    您可以像这样使用AppleScript,保存为应用程序:
tell application "Mail"
    set my_message to make new outgoing message
    set subject of my_message to "I restarted."
    set content of my_message to "Not sure why it happened..."
    set sender of my_message to "macman@christianboyce.com"
    --
    tell my_message
        make new to recipient at end of to recipients with properties {name:"macman@christianboyce.com"}
    end tell
    --
    send my_message
end tell
显然,您会将发件人和“收件人”更改为您自己的电子邮件地址。
然后,您可以将脚本保存为应用程序,并将其添加到您的登录项目中。 (这假设您的Mac设置为自动登录。)查看图片。我的登录项中显示的最后一项是脚本应用程序。
关键是将脚本保存为应用程序。那样,而不是 开盘 脚本,你正在执行它。