Perl Basics
Introduction to Perl
FAQ's
CGI
Regular Expressions

PC Overview
Cool Stuff
My Modules
Success Stories
Links
Perl in the News
Logos
Perl @ msn
Perl Chat

PC Internals
About
Contact
Guest Book
Handy Logos
What's new

Auf der CMD-Line Atachements verschicken

See also MIME::Lite
P-friendly

[ home ] - [ search ] - [ sitemap ]

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;
home - feedback - search - web jobs
© 1998-2004 retoh :)