[英]Sending mail using mailx
I'm trying to send mail using Mailx and uuencode with attachments using the following in a shellscript 我正在尝试使用Mailx和uuencode发送邮件,并在shellscript中使用以下附件
attachments=uuencode file1 file1;uuencode file2 file2;
(echo BODY ; $attachments )| mailx -s "Attachments" -m someone@mail.com
For the above script only mail without attachment is sent,However when i use the following 对于上述脚本,仅发送不带附件的邮件,但是当我使用以下脚本时
(echo BODY ; uuencode file1 file1;uuencode file2 file2;)| mailx -s "Attachments" -m someone@mail.com
Now mail is sent with the attachments. 现在,邮件将随附件一起发送。
I'm fairly new shellscripting kindly help. 我是相当新的shellscript帮忙。
You are using the wrong quotes for command substitution: 您为命令替换使用了错误的引号:
attachments=`uuencode file1 file1;uuencode file2 file2`
or better 或更好
attachments=$( uuencode file1 file1;uuencode file2 file2 )
See the Command Substitution section of the bash man page 请参见bash手册页的“ 命令替换”部分
And then use echo
to output the variable content 然后使用
echo
输出变量内容
(echo BODY ; echo $attachments )| mailx -s "Attachments" -m someone@example.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.