This uses MIME::Lite to send the named files as attachments. Customize by adding your email address and (optionally) specifying an SMTP server to use (running sendmail locally is the default). Run with no arguments (or read the code) to see the possible arguments.
#!/usr/bin/perl -w use MIME::Lite; use Getopt::Std; $FROM = 'me@example.com'; ### CHANGE THIS DEFAULT # MIME::Lite->send('smtp', "localhost:1025", Timeout=>60); ### Uncomment that line and adjust to send via specified SMTP server getopts('t:s:', \%o); $o{t} ||= $FROM; $o{s} ||= 'Your binary file, sir'; unless (@ARGV) { die "usage:\n\t$0 [-s subject] [-t to] file ...\n"; } $msg = new MIME::Lite( From => $FROM, To => $o{t}, Subject => $o{s}, Data => "Hi", Type => "multipart/mixed", ); while (@ARGV) { $msg->attach('Type' => 'application/octet-stream', 'Encoding' => 'base64', 'Path' => shift @ARGV); } $msg->send();--Nat
Re:Did just the same thing today
Matts on 2002-05-14T09:32:58
tilde expansion should happen in the shell before perl sees your command line arguments.Re:Did just the same thing today
gnat on 2002-05-14T15:21:55
Matt's right. If you're on Windows, add this after the call to getopts:That expands wildcards (dunno what it does for ~, though!) on Windows.@ARGV = map {glob} @ARGV;--Nat
(I thank perlmonks every time I use that!)