Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gnat (29)

gnat
  (email not shown publicly)

Journal of gnat (29)

Monday May 13, 2002
05:40 PM

Doodad of the Day

[ #4887 ]
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.