Perl: Mails mit Attachments versenden
Nach eimem Vorschlag von Eberhard Endres

Man installiert das Paket perl-MIME-Lite mittels
rpm -ihv perl-MIME-Lite<version>.rpm
Danach kann man z.B. mittels folgendem Perlprogramm Mails mit angehäntem Attachment versenden:
#! /usr/bin/perl
#
# Mails mit Perl versenden mit Attachments
# perl-MIME-Lite muss installiert sein
# -------- R. Bernert 2003 ---------------
use MIME::Lite;

Mail_File("za186\@lehrer.uni-karlsruhe.de",
          "za186\@suse81.tmg.de",
          "Attachment-Test",
          "Das ist ein Attachment - Test \nMal sehen ob's klappt!",
          "BINARY",
          "/home/za186/public_html/test.gif",
          "test.gif");
 

sub Mail_File {
 my $myMailAddress =$_[0];   # Senders mail address
 my $email_address =$_[1];   # Recipients mail address
 my $title         =$_[2];   # Email title
 my $body_message  =$_[3];   # Text in main part of e-mail
 my $fileType      =$_[4];   # attachment is 'BINARY'or 'TEXT'
 my $fileName      =$_[5];   # Name of file to attach (including path)
 my $outFileName   =$_[6];   # Name to give e-mail attachment

 # Create MIME::Lite mail object
 my $msg =MIME::Lite->new(
          From     => $myMailAddress,
          To       => $email_address,
          Subject  => $title,
          Type     => 'multipart/mixed',
          );

 # Main Body of message
   $msg->attach(
        Type     => 'TEXT',
        Data     => $body_message
        );

 # Attach file here
   $msg->attach(Type        => $fileType,
                Path        => $fileName,
                Filename    => $outFileName,
                Disposition => 'attachment'
                );
  # Send e-mail
     $msg->send();
} # end sub Mail_File



Roland Bernert