Skip to content

Instantly share code, notes, and snippets.

@adidonato
Created September 7, 2015 13:45
Show Gist options
  • Save adidonato/8c9b832d65e4181a28af to your computer and use it in GitHub Desktop.
Save adidonato/8c9b832d65e4181a28af to your computer and use it in GitHub Desktop.
Mac osx: Send files via email using Mail.app from the terminal
#!/bin/bash
###################################################################
# usage: ./compose_apple_mail.sh 'address' 'Subject' path_to_file #
# no arguments are compulsory #
###################################################################
echo "tell application \"Mail\"
activate
set MyEmail to make new outgoing message with properties {visible:true, subject:\"$2\", content:\"I am emailing you the following file: $3 \n\n \"}
tell MyEmail
make new to recipient at end of to recipients with properties {address:\"$1\"}
make new attachment with properties {file name:((\"$3\" as POSIX file) as alias)}
end tell
end tell
" | osascript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment