From time to time I need to send an E-mail with MIME attachments from the command line while logged on via an SSH connection. Thanks to Google, I found a shell script to do just that, and it only requires one modification (detailed below) to work on Mac OS X 10.3. (10.2 users must also install a perl package.) The original script is by Dave Wotton. My modified Mac OS X version is also available for download.
The shell script requires that your Mac be configured as a mail server that can send mail using the sendmail command (Mac OS X 10.3 uses postfix, but it still has a sendmail command for compatibility purposes). The script also requires perl with the MIME::Base64 package installed. This package comes with Mac OS X 10.3 (10.2.x users must install it, though). The one modification I made to the script is to change the /usr/bin/sendmail command to /usr/sbin/sendmail, the correct path on Mac OS X.
Here is how to make it work.
% chmod u=rwx,go=rx mail_files
% tar -zxvf MIME-Base64-3.00.tar.gz
% cd MIME-Base64-3.00
% perl Makefile.PL % make % sudo make install
% mail_files -t recipient@email.address -s subject -b attachedFileName Enter your message text here in as many lines as necessary with control-D at the end. [Ctrl-D]Edit the script for a detailed description of all the options in the comments. E-mail away!
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040210105313440