Sending Mail From Bash Scripts with an Attachment
Here is a great little tut on getting started in Bash. I’d recommend it to anyone trying to hack their way into a shell script.
Here is a quick script for sending an email:
#!/bin/bash # Subject of email SUBJECT="Test email with attachment from a bash script" # Where to send it TO_ADDRESS="your@email.com" # Where the attachment is ATTACHMENT_FILE="/tmp/attachment.txt" # For fun, let's put something into the attachment echo "This goes into the file." > $ATTACHMENT_FILE echo "This appends to the file." >> $ATTACHMENT_FILE # send the message /bin/mail -s "$SUBJECT" "$TO_ADDRESS" < $ATTACHMENT_FILE |