我正在尝试使用sendmail命令在shell脚本中发送电子邮件。我已成功发送附带.txt文件的电子邮件。以下是我的工作代码示例:
echo "Please enter a valid email address:"
read EMAIL
uuencode results.txt results.txt | sendmail $EMAIL
但是,当我尝试添加主题和正文时,例如:
uuencode results.txt results.txt | sendmail $EMAIL<<EOF
subject: Log file from today
Test
EOF
邮件正常发送但没有附件。有任何想法吗?我是C ++和VB人。
感谢。
答案 0 :(得分:0)
为什么不将uuencode的结果放入变量?假设Bash:
ENCODED=`uuencode results.txt /dev/stdout`
echo "Please enter valid email address:"
read EMAIL
sendmail $EMAIL <<EOF
Subject: This is a test
Test file attached
--------------
$ENCODED
EOF