How to specify Subject line with the sendmail command?
You need to provide the headers. sendmail will add some headers if you fail to provide them (such as Message-Id, Date...) but it expects that you provide the headers. sendmail is to send raw emails. You should consider using the mailx command instead.
sendmail -oi -t << EOF
Body of the message
The headers are separated from the body by an empty line.
"-t" tells sendmail to look for the addresses to send this to in the To: and Cc: (and possibly Bcc: in which case it will remove it before sending the email) headers of the message.
For mailing text, I would use
mail -s "subject here" email@example.com < filename_here
mailx -s "subject here" firstname.lastname@example.org < filename_here
Send mail isn't intended at a user interface. You can type, line-for-line something like:
send mail email@example.com
Note the line that begins with "Subject:" triggers the subject line. The ^D is a control_D which signifies end-of-file.
Have a Unix Problem
Return to : - Unix System Administration Hints and Tips
(c) www.gotothings.com All material on this site is