Operating System - HP-UX
1833863 Members
2293 Online
110063 Solutions
New Discussion

Add subject line for mail

 
SOLVED
Go to solution
Ed Hon
Regular Advisor

Add subject line for mail

I have a cron script that sends mail to root, if it finds a certain condition. The command looks like 'echo "Bad stuff just happened" | mail root ', but there is no subject shown, if I view it with elm. How do I include a subject line? Thanks.
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor

Re: Add subject line for mail

Hi:

Use the '-s' option with mailx, like:

# mailx -s "This is the subject!" root < /tmp/mailmsg

...JRF...
Dan Hetzel
Honored Contributor
Solution

Re: Add subject line for mail

Hi Ed,

Use mailx instead of mail, you'll be able to add a subject flag (-s) like this:

echo "Bad stuff just happened" | mailx -s "Bad stuff" root

Best regards

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Darrel Louis
Honored Contributor

Re: Add subject line for mail

You can use the following:

mailx -s "hello world" root < filename

Check man mailx for more options.

Good Luck
CHRIS_ANORUO
Honored Contributor

Re: Add subject line for mail

Use 'echo "Bad stuff just happened" | elm -s "Bad stuff" root'
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.