我尝试以这种方式从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$%有人能告诉我怎么解决这个问题吗?
发布于 2011-03-30 00:55:14
请看我对这个问题的回答:如何在Unix bash脚本中发送附件的How to send HTML body email with multiple text attachments using sendmail。
编辑
根据您的最新要求,这里提供了一个简单的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 https://stackoverflow.com/questions/5474127
复制相似问题