#!perl -w use strict; use warnings; use File::Basename; use MIME::Lite; sub email { my ($smtp_server, $to) = @_; my $msg = MIME::Lite->new( From => basename($0) . '@' . $ENV{COMPUTERNAME}, To => $to, Subject => "Nur ein Test", Type => 'multipart/mixed', ); # email-Body dazu $msg->attach( Type => 'TEXT', Data => "Habe fertig!\n", ); # email-Anhänge dazu $msg->attach( Type => 'text/plain', Path => $0, Filename => basename($0), ); eval { # email abschicken $msg->send('smtp', $smtp_server); }; if($@) { print STDERR "Fehler beim Verschicken der email\n"; } } # email versenden email("smtp-server.irgendwo.de", "fritz\@daheim.de");