sha*_*nuo 7 email email-server
如何抑制空白电子邮件?例如,在下面的例子中,我想
some command | mail -s "tables altered on `hostname`" me@company.com
Run Code Online (Sandbox Code Playgroud)
发送消息后,我收到以下消息:
Null message body; hope that's ok
Run Code Online (Sandbox Code Playgroud)
这不行。如果没有文字,我不想发送邮件。
Sve*_*ven 15
#!/bin/sh
string=`some command`
len=${#string}
if [ "$len" -gt "0" ]
then echo $string | mail -s "tables altered on `hostname`" me@company.com
fi
Run Code Online (Sandbox Code Playgroud)
仅当命令的输出长度至少为 1 个字符时才会发送邮件,但这可能包括空格等。
(上述解决方案有效,但没有必要。man mail
显示 -E 选项):
some command | mail -E -s "tables altered on `hostname`" me@company.com
Run Code Online (Sandbox Code Playgroud)
小智 8
我使用以下内容:
$ mail --exec 'set nonullbody' -s Test test@example.com
Run Code Online (Sandbox Code Playgroud)
我在GNU 邮件文档中的nullbody部分找到了它。
归档时间: |
|
查看次数: |
4770 次 |
最近记录: |