what I am trying to do is create a function have it load when type the letter "m" so all have to do type an address after it send email. it tell me syntax on line 4 but which one??
Some time ago I wrote a script "fmail" which uses mailx program and is
able to write simple text mails as well as sending attachments, too.
Maybe you can make some use out of it. After starting the script with the desired
command line arguments it enters into editing mode, where you may write message body text.
Entering a single "." on a line (followed by Return key) sends the message.
#!/bin/sh
test $# -eq 0 && echo "usage: `basename $0` user@host [filename(s)]" && exit 0
myaddr=yourname@yourdomain
if test "$1" == "me"; then
addr=$myaddr
else
addr=`expr match "$1" '\(.*@.*\)'`
test -n "$addr" || (echo "malformed email address: $1"; exit 1) || exit 1
fi
shift
from="-r $myaddr"
metoo=""
if test "$addr" != $myaddr; then
metoo="-c $myaddr"
fi
if test $# -eq 0; then
echo mailx $from $metoo $addr
env MAILRC=/dev/null mailx $from $metoo $addr
exit 0
fi
for fname in $@; do
test -f "$fname" || (echo "file $fname does not exist"; exit 1) || continue
fdir=`dirname $fname`
fbase=`basename $fname`
subject="${subject}${sep}${fbase}"
fileargs="${fileargs}${sep}-a \"$fname\""
sep=" "
done
echo mailx -s \"$subject\" $fileargs $from $metoo $addr
eval env MAILRC=/dev/null mailx -s \"$subject\" $fileargs $from $metoo $addr