简体   繁体   English

mailx 将 email 发送到多个帐户

[英]mailx sending email to multiple accounts

I am trying to use mailx to send an email via shell script.我正在尝试使用 mailx 通过 shell 脚本发送 email 。

Message=<HTML><BODY><p>FINISHED</p></BODY></HTML>

Recipients=email1@email.org;email2@email.org
Recipients=$(echo "${Recipients}" | sed "s/;/ /g")
echo "Recipients:  ${Recipients}"

mailx -s "Ingestion Report ${EXT1}. $( echo "\nContent-Type: text/html")" "${Recipients}" < $MESSAGE

my problem is I'm trying to change the list delimited by a semi-colon to a space-delimited list because I"m told that is what's needed by mailx.我的问题是我正在尝试将由分号分隔的列表更改为以空格分隔的列表,因为我被告知这是 mailx 所需要的。

However, the response is:然而,回应是:

sh: email2@email.org:  not found

what am I doing wrong?我究竟做错了什么? thanks.谢谢。

A semicolon is a command separator, so you have to change how you are defining Recipients from:分号是命令分隔符,因此您必须更改定义Recipients的方式:

Recipients=email1@email.org;email2@email.org

To:至:

Recipients="email1@email.org;email2@email.org"

Quoting the value prevents the ;引用该值可防止; from being interpreted as a command separator.从被解释为命令分隔符。

Alternatively, you can just define Recipients correctly in the first place:或者,您可以首先正确定义Recipients

Recipients="email1@email.org email2@email.org"

Or if you don't control that for whatever reason, you can drop the sed call and just do:或者,如果您出于某种原因无法控制它,您可以放弃sed调用,然后执行以下操作:

mailx ... ${Recipients/;/ }

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM