I'm trying to make a bash script that will send an email to all contacts which will contain a message and an attachment. This is not for malicious purposes.
How could I do this? Is this possible? Thanks in advance.
You might 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:"[email protected]", 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 run handler to pass arguments from a 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;[email protected]
Name2;[email protected]"
I have previously used uuencode to accomplish this:
uuencode source.txt destination.txt | mail -s "subject of mail" [email protected]
You can use this in your bash script. Sample:
uuencode /usr/bin/xxx.c MyFile.c | mail -s "mailing my c file" [email protected]
http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds5/uuencode.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With