Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set Mail Subject and Mail content by mail command in shell?

Status
Not open for further replies.

micotao

Programmer
Jun 16, 2004
33
CN
Hi, All:
I'd like to write a script which can send email to some specific receivers. I want to use mail command in my shell script to realize this, but I don't know how to set the Mail Subject,(say, "Test Email") when calling mail command in shell script. I don't want to input by interactive way, but only want to set the Mail Subject using some option of mail utility? Is there such an option?
I hope you can give me help.
Your kindly help will be highly appreciated.
 
man mail
man mailx

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi, PHV:
Thanks for your help.
I have use man mail to see, but I can't find such an option for specifiying Subject of one email. Does this means, mail command doesn't support this specifying Subject?
I use man mailx, and found such options which seems to make sense. It can use -s to specify the Subject string, and I guess it can use < to read message contents(message body) to the mailx command.But what makes me confused is that there is something totally diffent for "mail" and "mailx" command from each other. Say, -t means to display To:(reciepient) field; while -t means to ignore all reciepients on the command line if you use mailx -t.
Does this mean, I can only use mailx to realize my requirement, specifying Subject field when calling the command in shell scripts. AM I right, PHV?
Thanks in advance!
 
Hi, PHV:
Again, as I mentioned in my last reply, -t in mailx will ignore all recipients in the commond line, then how can we display the To: field if we use mailx command? That is, although the mail is sent successfully, but we can't see the To: field in some email receiving interface (say, Outlook).
Do you think there is some solution to this issue? That is, not only to display the To: field but also to support Subject specifying on command line?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top