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:
#!/bin/bash # email send script example # # subject of email SUBJECT="BASH SAYS HELLO" # destination EMAIL="firstname.lastname@example.org" # 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