[英]Mac Terminal Sending Email With Attachment
我正在嘗試制作一個bash腳本,它會向所有包含郵件和附件的聯系人發送電子郵件。 這不是出於惡意目的。
我怎么能這樣做? 這可能嗎? 提前致謝。
我以前使用過uuencode來完成這個:
uuencode source.txt destination.txt | mail -s "subject of mail" youremail@yourdomain.com
您可以在bash腳本中使用它。 樣品:
uuencode /usr/bin/xxx.c MyFile.c | mail -s "mailing my c file" youremail@yourdomain.com
您也可以使用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
您可以使用顯式運行處理程序從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"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.