You can also use AppleScript:
tell application "Mail" tell (make new outgoing message) set subject to "subject" set content to "content" -- set visible to true make new to recipient at end of to recipients with properties {address:" name@example.com ", name:"Name"} make new attachment with properties {file name:(POSIX file "/tmp/test.txt")} at after the last paragraph send end tell end tell
You can use an explicit startup handler to pass arguments from the shell:
osascript -e 'on run {a} set text item delimiters to ";" repeat with l in paragraphs of a set {contact, address} to text items of l end repeat end run' "Name1; name1@example.com Name2; name2@example.com "
source share