Created
September 12, 2011 19:40
-
-
Save nikcub/1212180 to your computer and use it in GitHub Desktop.
send email with mail.app via terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "[email protected]" | |
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