Did you ever need to have e-mail’s sent from within a bash script? Maybe alert you of errors encountered? Me too.
Here’s an easy way on how to do it:
View Code BASH
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/bin/bash # email send script example # # subject of email SUBJECT="BASH SAYS HELLO" # destination EMAIL="user@yourdomain.com" # Email body EMAILMESSAGE="/tmp/messagebody.txt" echo "Email sent from BASH" > $EMAILMESSAGE echo "Another text line" >> $EMAILMESSAGE # send message using /bin/mail /bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE |
Easy.