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.
I have previously used uuencode to accomplish this:
uuencode source.txt destination.txt | mail -s "subject of mail" youremail@yourdomain.com
You can use this in your bash script. Sample:
uuencode /usr/bin/xxx.c MyFile.c | mail -s "mailing my c file" youremail@yourdomain.com
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:"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 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;name1@example.com
Name2;name2@example.com"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.