Assign the values to shell variables. It makes interpolation cleaner.
end "here documents" (
<<MXXX
)use
-i
sendmail command line optionseparate email email headers an body with empty line
Modified script:
HOSTNAME=`hostname`
SENDER="Root@${HOSTNAME}.com"
RECIPIENT="abc@xyz.com"
sendmail -t -i -f${SENDER} <<TEST_MAIL
From: Root <${SENDER}>
To: <${RECIPIENT}>
Subject:Password Expiry
Hi,
Root Users's Password will expire in $1 days
Consider changing it soon.
Regards
System
TEST_MAIL