I have a bash script that I use with nagios that sends notifications by email. The key part of it looks like this:# $1 (FROM) | $2 (TO) | $3 (SUBJECT) | $4 (BODY)/usr/bin/printf %b $4 | /bin/mail -s $3 $2 -- -f $1I know I could use the sendmail command directly (like this) but it would mean reworking a few scripts to take care of building the entire message including all headers.Is there any way to specify additional SMTP headers using /bin/mail, in my own case I am trying to add the Importance: high header?I'm running exim 4.63 as my MTA and CentOS 5.6 x64.
Setting headers using the /bin/mail command
email;mail command
There are many different versions of mail (see Mail vs. mail what is the difference and the Heirloom project's write-up on the different versions of mail).If you want to keep your sanity, I recommend avoiding any tool whose name is too close to mail. Mutt is a lean text mode mail client which is often available, very flexible, and behaves the same everywhere.mutt -H - $2 <<EOFFrom: $1To: $2Subject: $3Importance: high$4EOF