1.#!/bin/bash # script to send simple email # email subject SUBJECT="SET-EMAIL-SUBJECT" # Email To ? EMAIL="admin@test.com" # Email text/message EMAILMESSAGE="/tmp/body.txt" echo "This is an email message test"> $EMAILMESSAGE echo "This is email text" >>$EMAILMESSAGE # send an email using /bin/mail /bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
2.#!/bin/sh while true do subject="your-email-bsubject" mailaddr="admin@example.com" message=`you-email-body` encsubject=`echo $subject` cat << EEE | mail -s "$encsubject" $mailaddr $encsubject $message EEE exit 0 done
This is the blog about linux server and business English experience of my life.
Monday, October 24, 2011
Send mail bash script
Sample Shell Script
Here are two samples of shell script to send an email:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment