UNIX mail utilities long predated the attachment schemes improvised in the mid 90's. You'll need to use a specialized utility, a custom
perl-script, or a full-fledged mail program (such as pine). Here's a
perl script to help; but it will require some modules (MIME::Lite and dependencies) to be installed. It only does one attachment at a time, but you can modify it, right?
Code:
#!/usr/bin/perl -w
use MIME::Lite;
use Getopt::Std;
our ($opt_d,$opt_s,$opt_f, $opt_h);
getopt('ds:f:h:');
# Specify the mailhub with -h (or localhost used)
# Specify recipients on the command line
# Specify the file to be attached with -f (only one)
# Subject with -s
### Create a new multipart message:
my $msg = MIME::Lite->new(
From => $ENV{USER} . '@' . `hostname -f`,
Subject => $opt_s,
Type => 'multipart/mixed'
);
### Add parts (each "attach" has same arguments as "new"):
my (@text) = <STDIN>;
(scalar(@text)) and $msg->attach(
Type => 'TEXT',
Data => \@text
);
$opt_f and $msg->attach(
Type => 'application/zip',
Path => $opt_f,
Filename => $opt_f,
Disposition => 'attachment'
);
### use Net:SMTP to do the sending
for (@ARGV) {
$msg->replace('To',$_);
$msg->send('smtp',($opt_h || "localhost"), Debug=> ($opt_d ? 1 : 0) );
}