Skip to content

Instantly share code, notes, and snippets.

@nikcub
Created September 12, 2011 19:43
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nikcub/1212184 to your computer and use it in GitHub Desktop.
Save nikcub/1212184 to your computer and use it in GitHub Desktop.
Send email with Mail.app from command line script
#!/bin/sh
/usr/bin/osascript > /dev/null <<ASCPT
set stdinText to "$(cat | sed -e 's/\\/\\\\/g' -e 's/\"/\\\"/g')"
set recName to "Nik Cubrilovic"
set recAddr to "nikcub@gmail.com"
set theSubject to "Email from standard input"
tell application "Mail"
set theMessage to make new outgoing message with properties {subject:theSubject, content:stdinText, visible:true}
tell theMessage
make new to recipient with properties {name:recName, address:recAddr}
send
end tell
end tell
ASCPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment