Wednesday, December 5, 2012

Sending Emails From Scripts

We may need to send an email from our scripts, typically as a notification of completion or failure of a scheduled task. There are three ways to do this - mail, mailx and sendmail.

cat mailtext.txt | mail -s "This is the subject" addresslist.txt

cat mailtext.txt | mailx -s "This is the subject" addresslist.txt

cat mailtext.txt | sendmail -f admin@hostname addresslist.txt

No comments:

Post a Comment