How to send email using bash script

You may use “mail” command under Linux or UNIX bash shell to send an email. In order to send a mail to one or more people

You may use mail -s [email protected] then type text then Ctrl+D then Cc

However you may use bash script for sending that very simple:

#!/bin/bash
MAIL=”[email protected]

SUBJECT=”Hello I’m your notification”

MESSAGE=”/tmp/message.txt”

echo “Notification email”> $MESSAGE
echo “Some text” >>$MESSAGE

/bin/mail -s “$SUBJECT” “$MAIL” < $MESSAGE

You may also check where is mail is located using

which mail

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *