mail from script or CLI

From thelinuxwiki
Revision as of 20:17, 4 February 2014 by Nighthawk (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

I was having trouble setting my subject line on emails. They were coming in blank. I had to put Subject: into the string and then it worked. My mail program is sendmail, but I think the binary was replace with postfix sendmail...? not sure...

# ls -l /usr/sbin/mail
/usr/sbin/mail -> /usr/sbin/sendmail

mail from CLI test

# printf "Subject:my subject\nmy body\n" | /usr/sbin/mail -F sender@atsomeemail.com me@myemailaddress.com

in my script

echo "Subject:${EMAILSUBJECT}" | cat - $LOGFILE  | /usr/sbin/mail -F sender@atsomeemail.com $EMAILADDRESS

all this was working and tested