Linux mailx 功能不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15006711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mailx function is not working
提问by Teja
I am trying to use mailx function to send an e-mail to my personal email address.But I never received an email.Can someone help me pls. Here is my command below.
我正在尝试使用 mailx 功能向我的个人电子邮件地址发送电子邮件。但我从未收到电子邮件。有人可以帮助我吗?下面是我的命令。
PRI_EMAIL_SUBJECT="Some Blah Blah"
PRI_EMAIL_ADDRESS="[email protected]"
PRI_EMAIL_BODY="$PRI_SETS_RAN_SUCSFL_CNT no. of sets ran successfully."
echo "Sending e-mail"
mailx -s $PRI_EMAIL_SUBJECT $PRI_EMAIL_ADDRESS < $PRI_EMAIL_BODY
echo
采纳答案by Teja
回答by suspectus
Use the -d option of mailx for debug output. This may indicate an issue with the mail transport.
使用 mailx 的 -d 选项进行调试输出。这可能表示邮件传输存在问题。
mailx -d -s $PRI_EMAIL_SUBJECT $PRI_EMAIL_ADDRESS < $PRI_EMAIL_BODY
回答by tripleee
You cannot redirect a string. mailx <$FOO
expands the variable FOO
and attempts to find a file named like that. But since you (presumably) do not have a file named 3 no. of sets ran successfully.
you get a redirection error, and the command fails.
您不能重定向字符串。 mailx <$FOO
展开变量FOO
并尝试找到一个这样命名的文件。但是由于您(大概)没有名为的文件,3 no. of sets ran successfully.
您会收到重定向错误,并且命令失败。
To actually send the contents of the variable as email, try
要将变量的内容作为电子邮件实际发送,请尝试
echo "$PRI_EMAIL_BODY" | mailx
(or maybe use a here document).
(或者可能使用此处的文档)。