All Things Techie With Huge, Unstructured, Intuitive Leaps

Sending Mail From Linux Using Bash Shell

This was a quick and dirty bash shell for send email from a command line. The body of the email was the same, and the email was going out to a bunch of people.

Using vi, I created a file in /home/tmp/mailmessages with the body of what I want to write. For this example it is /home/tmp/mailmessages/myFileTellingEveryone

Then I created the following bash script, name mymailer and put in the /bin or /sbin directory:

#FILE= "/home/tmp/mailmessages/$3"
#echo $(basename "$2")
mail -s $(basename "$2") $(basename "$1") < /home/tmp/mailmessages/$(basename "$3")

Do a chmod so that you can execute it (chmod 777 works for me) and now all I do is type:

#mymailer "This is my Subject" myFileTellingEveryone

I just keep changing the email address and I can send out this way.

No comments:

Post a Comment