Skip to content

Instantly share code, notes, and snippets.

@nikcub
Created September 12, 2011 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikcub/1212180 to your computer and use it in GitHub Desktop.
Save nikcub/1212180 to your computer and use it in GitHub Desktop.
send email with mail.app via terminal
#!/bin/sh
/usr/bin/osascript > /dev/null <<ASCPT
set stdinText to "$(cat | sed -e 's/\\/\\\\/g' -e 's/\"/\\\"/g')"
set recipientName to "John Doe"
set recipientAddress to "nobody@nowhere.com"
set theSubject to "Email from standard input"
set theContent to "This email was created and sent using AppleScript!"
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:recipientName, address:recipientAddress}
send
end tell
end tell
ASCPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment