Mac Terminal Sending Email with the Application

I am trying to make a bash script that will send an email to all contacts that will contain a message and attachment. This is not for malicious purposes.

How can i do this? Is it possible? Thanks in advance.

+6
source share
2 answers

Earlier I used uuencode for this:

uuencode source.txt destination.txt | mail -s "subject of mail" youremail@yourdomain.com 

You can use this in your bash script. Example:

 uuencode /usr/bin/xxx.c MyFile.c | mail -s "mailing my c file" youremail@yourdomain.com 

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds5/uuencode.htm

+9
source

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 " 
+1
source

Source: https://habr.com/ru/post/958531/


All Articles