***** infoCopter.com/perl *****

Auf der CMD-Line Atachements verschicken



Auf der CMD-Line Attachments verschicken

#!/usr/bin/perl -w
use strict;

unless ($ARGV[0]) {
        print q~
        script {To} {Subject} {path to attachment}
~;
        exit;
}

        eval("use LocMIMELite");
        die "Seems MIME::Lite is'nt installed yet on this machine $@" if $@;
        my $message = LocMIMELite->new(
                From     => 'reply@yourhost.com' ,
                To       => $ARGV[0] ,
                Subject  => $ARGV[1] ,
                Type     => 'text/plain',
                Encoding => '8bit',
                Data     => "Dear Sirs,\n\nEnjoy your attachment $ARGV[2]"
        );

        my ($mime_type, $encoding) = ('application/octet-stream', 'base64');

        $message->attach (
                Type     => $mime_type ,
                Encoding => $encoding ,
                Path     => $ARGV[2] ,
                Filename => $ARGV[2]
        );

        # -----  Tell MIME::Lite to use Net::SMTP instead of sendmail
        LocMIMELite->send('smtp', 'smtp.mysunrise.ch', Timeout => 20);

        $message->send;
© reto :)