forked from eisop-plume-lib/plume-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail-e
More file actions
executable file
·28 lines (22 loc) · 713 Bytes
/
mail-e
File metadata and controls
executable file
·28 lines (22 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /bin/sh
# No "-f" argument above?
# This script reads standard input, and if not empty calls the "mail"
# program on it.
# In other words it is a version of "mail" that assumes the -e argument:
# -e Don’t send empty mails. If the body is empty skip the mail.
# That feature is useful in scripts and cron jobs, but is not supported
# in all versions of mail.
# Read standard input
BODY=/tmp/maile-input-$$
cat > $BODY 2>&1
# Invoke mail if body is non-empty.
if [ -s $BODY ]; then
# Non-empty body
mail "$@" < $BODY
fi
rm -f $BODY
## Testing
## This should produce no error
# echo -n "" | mail-e -invalidoption
## This should send the mail
# echo -n "body" | mail-e -s "The subject" $USER