繁体   English   中英

Mac终端发送带附件的电子邮件

[英]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

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

您也可以使用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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM