简体   繁体   English

通过电子邮件发送多个文件,并向电子邮件添加正文消息(Unix Korn Shell)

[英]Send multiple files by email and also add a body message to the email (Unix Korn Shell)

I'm trying to send multiple files by email but also include a body message in the email, I've tried couple of ways with no luck, the following code is for send multiple files:我正在尝试通过电子邮件发送多个文件,但也在电子邮件中包含正文消息,我尝试了几种方法但没有成功,以下代码用于发送多个文件:

(uuencode file1.txt file1.txt ; uuencode file2.txt file2.txt) | mailx -s "test" email@test.com

I've tried this option with no luck:我试过这个选项但没有运气:

echo "This is the body message" | (uuencode file1.txt file1.txt ; uuencode file2.txt file2.txt) | mailx -s "test" email@test.com

any idea how could be the code?任何想法怎么可能是代码?

Try this:尝试这个:

(echo "This is the body message"; uuencode file1.txt file1.txt; uuencode file2.txt file2.txt) | mailx -s "test" email@test.com

The issue with your command is that you are piping the output of echo into the subshell and it is getting ignored as uuencode isn't reading from stdin.您的命令的问题在于,您正在将echo的输出通过管道echo到子外壳中,并且由于uuencode未从 stdin 读取而被忽略。

You can use { ... } to avoid the subshell:您可以使用{ ... }来避免子shell:

{ echo "This is the body message"; uuencode file1.txt file1.txt; uuencode file2.txt file2.txt; } | mailx -s "test" email@test.com

If you are doing this in a script and you want it to look more readable, then:如果您在脚本中执行此操作并且希望它看起来更具可读性,那么:

{
  echo "This is the body message"
  uuencode file1.txt file1.txt
  uuencode file2.txt file2.txt
} | mailx -s "test" email@test.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用附件和HTML消息正文从UNIX命令发送电子邮件 - Send email from UNIX command with attachment and HTML message body 使用unix shell命令发送简单的电子邮件 - send simple email using unix shell command Unix Shell脚本不发送预期的电子邮件 - Unix Shell Script does not send intended email 如何将多个文件复制到不同的文件夹中删除每个文件上的一些字符 | unix korn 外壳 - How to copy multiple files to a different folder removing some characters on each one | unix korn shell 替代UNIX Shell脚本中的uuencode(从UNIX框发送电子邮件) - substitute for uuencode in UNIX shell scripting (to send an email from UNIX box) 如何在AWK上发送参数以替换参数。 Unix Korn Shell - How to send parameters on AWK to replace a parameter. Unix Korn Shell 如何在unix korn shell中grep'*' - How to grep '*' in unix korn shell 使用Shell和smtp在电子邮件正文中发送内容以及附件 - Using Shell and smtp to send content in email body along with attachment 如何在Unix中发送带附件的电子邮件 - How to send email with attachment in Unix 试图从今天的日期和结果中获取文件时,也会显示昨天的日期文件(Unix Korn Shell) - Trying to get files from today date and result is displaying yesterday date files as well (Unix Korn Shell)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM