如果您使用未安装其他软件的 Solaris 来发送 MIME 邮件:如何使用标准命令行工具发送带有 MIME 附件的邮件?
答案1
您可以在 shell 脚本中使用以下代码片段。这无疑是一种非常丑陋的 hack,因此请仅在不重要的事情上使用它。我认为它可能会在文件末尾添加一个或两个字节,但除此之外,它似乎工作正常。
mail ${mailinglist} << END_MAIL
To: ${mailinglist}
From: ${mailsender}
Subject: ${subject}
Content-Type: multipart/mixed; boundary="_NextPart_"
Content-Type: text/plain; charset=us-ascii
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--_NextPart_
Hallo,
here is whatever.zip.
--_NextPart_
Content-Type: application/x-zip-compressed;
name="whatever.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="whatever.zip"
`
uuencode whatever.zip whatever.zip | sed -e 's/^end$/~~~/' | tail +2 | cut -c 2- |
tr ' !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\133\134\135^_' \
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' |
sed -e 's/^~~$/==/'
`
--_NextPart_--
END_MAIL