As much as it wasn’t designed as one, the convenience of email has led to its widespread use as a file transfer protocol.

I’m currently evaluating ways to leverage this fact more effectively (such as for blog posting), but in the meantime, I’ve found this little shell command to be very handy as a quick backup for text files:

cat test.rb | /usr/sbin/sendmail -t me@example.com

It won’t work for binary files; those require base64 encoding and attachment with mime data.

This page from shelldorado is awesome:

Sending e-mail using shell scripts

Yes, metasend from the metamail package (available on debian) works perfectly:

metasend -b -t user.name@example.com -s "Testing metasend" -m image/jpeg -f kilotronix_1.jpg-thumb-210x109-1709.jpg

To get the filename on the receiving side, I’m using the -D flag to set the content-description header.

metasend -b -t user.name@example.com -e base64 -s "Testing metasend" -m image/jpeg -D kilotronix_1.jpg-thumb-210x109-1709.jpg -f kilotronix_1.jpg-thumb-210x109-1709.jpg -n -m text/plain -f blah