[英]Using sendmail command while using uuencode to send attachment
I am trying to send an email in a shell script with the sendmail command. 我正在尝试使用sendmail命令在shell脚本中发送电子邮件。 I have successfully sent the email with a .txt file attached. 我已经成功发送了带有.txt文件的电子邮件。 Here is an example of my working code: 这是我的工作代码示例:
echo "Please enter a valid email address:"
read EMAIL
uuencode results.txt results.txt | sendmail $EMAIL
However, when I try to add a subject and body, for example: 但是,当我尝试添加主题和正文时,例如:
uuencode results.txt results.txt | sendmail $EMAIL<<EOF
subject: Log file from today
Test
EOF
The message sends properly but with no attachments. 邮件发送正确,但没有附件。 Any ideas? 有任何想法吗? I'm a C++ and VB guy. 我是C ++和VB专家。
Thanks. 谢谢。
Why not put the result of the uuencode into a variable? 为什么不将uuencode的结果放入变量? Assuming 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.