我试图通过shell脚本以这种方式发送带有uuencode的附件:
uuencode logq.txt logq.txt |mail -s "DB Capacity" xxxx@000.net
我收到加密的文件,甚至没有附上..
例如 -
begin 664 logq.txt
M"E1U92!-87(@,CD@(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @(" @<&%G92 @(" Q"B @(" @(" @ M(" @(" @(" @(" @(" @(" @(" @(" @4$U-($1"($-!4$%
有人可以告诉我如何解决它吗?
答案 0 :(得分:1)
请参阅我对这个问题的回答:How to send HTML body email with multiple text attachments using sendmail关于如何在Unix bash脚本中发送附件。
根据您的最新要求,这是一个简单的Unix脚本,用于发送纯文本附件:
FROM=from-email@example.com
TO=to-email@example.com
SUBJECT="PMM DB CAPACITY"
BODY="Hi, This email comes with a text attachment. Thanks!"
TXTFILE="/tti/netrac/integration/scripts/maint_scripts/log.txt log.txt"
BOUNDARY="=== This is the boundary between parts of the message. ==="
{
echo "From: ${FROM}"
echo "To: ${TO}"
echo "Subject: ${SUBJECT}"
echo "MIME-Version: 1.0"
echo "Content-Type: MULTIPART/MIXED; "
echo " BOUNDARY="\"${BOUNDARY}\"
echo
echo " This message is in MIME format. But if you can see this,"
echo " you aren't using a MIME aware mail program. You shouldn't "
echo " have too many problems because this message is entirely in"
echo " ASCII and is designed to be readable with old mail software."
echo
echo "--${BOUNDARY}"
echo "Content-Type: TEXT/PLAIN; charset=US-ASCII"
echo
echo "${BODY}"
echo
echo
echo "--${BOUNDARY}"
echo "Content-Type: TEXT/PLAIN; charset=US-ASCII; name="${TXTFILE}
echo "Content-Disposition: attachment; filename="`$(basename ${TXTFILE})
echo
cat ${TXTFILE}
echo
echo "--${BOUNDARY}--"
} | sendmail -t
请确保您的bash路径中有sendmail。
(echo "Hi, this mail has an attachment."; uuencode attachment.txt attachment.txt) | mail -s "Some Subject" to-email@example.com