Hallo alle!
Da steh ich nun, ich armer Tor! Und bin so klug als wie zuvor.
Leider habe ich mich geirrt. Und ich brauch trotzdem eure Hilfe. Warum funktioniert Skript 1 ? Und Skript 2 sendet nichts, macht aber auch keine Fehlermeldungen. Kann mir jemand verraten wie ich im Debugger den Inhalt von einem FILEHANDLE auslesen kann? Das wäre sehr hilfreich. Ich habe es so versucht: > x <SENDMAIL> Aber Antwort ist immer "empty Array" ...
Hier die Skripte. Das zweite brauche ich :-)
***Skript 1***
#!/usr/bin/perl
# Aus:
http://wiki.perl-community.de/Wissensba ... ttachments# funzt!
use strict;
use warnings;
use MIME::Base64;
my $file_path = "/Users/you/Documents/webpages/cgi-bin/tmp";
my $file_name = "ical_summary.ics";
open(M, "|/usr/sbin/sendmail -t -oi") or die "Can't open mailprogram: '/usr/sbin/sendmail'!\n$!";
print M "MIME-Version: 1.0\n";
print M qq(To: Your Name <you\@yourdomain.com>\n);
print M qq(From: Your Name <you\@yourdomain.com>\n);
print M qq(Reply-to: Your Name <you\@yourdomain.com>\n);
print M "Subject: E-Mail - the corrected version!\n";
my $boundary = "==========".substr(pack('u', ('E-Mail'.'Your Name')), 0, 24);
print M qq(Content-type: multipart/mixed; boundary="$boundary"\n);
print M qq(--$boundary\nContent-Type: text/plain; charset="UTF-8"\nContent-Transfer-Encoding: 7bit\n\n);
print M qq(\nUnd hier kommt ein Test jeflogen!\n);
print M "\n--$boundary\n";
print M qq(Content-type: application/octet-stream; name="$file_name"\n);
print M "Content-Transfer-Encoding: base64\n";
print M qq(Content-Disposition: attachment;\nContent-Type: text/calendar filename="$file_name"\nContent-Transfer-Encoding: base64\n);
open(F, "$file_path/$file_name") or die "Can't open data: '$file_path/$file_name'!\n$!";
my $data;
{
binmode F;
local $/;
$data = <F>;
}
close(F) or die "Can't close: '$file_path/$file_name'! $!\n";
my $codiert = MIME::Base64::encode($data);
print M "\n$codiert\n";
print M qq(\n--$boundary--\n);
close(M) or die "Can't close the filehandle <M>: $!";
__END__
***Skript 2*****
#! /usr/bin/perl
use strict;
use warnings;
use MIME::Base64;
my $mailprog = '/usr/sbin/sendmail -t -oi';
my $postmaster =
'you@yourdomain.com';
my @recipients = (
'info@anothedomain.de',
'marek@yourdomain.com' );
my $ical_data_start = "20120601T210000";
my $ical_data_end = "20120601T220000";
my $ical_summary = "Dinner";
my $ical_location = "Hörwartstr";
my $ical_file_name = $ical_summary . ".ics";
my $ical_data = <<"EOICAL";
BEGIN:VCALENDAR
BEGIN:VEVENT
DTEND;TZID=Europe/Berlin:$ical_data_end
SUMMARY:$ical_summary
DTSTART;TZID=Europe/Berlin:$ical_data_start
DTSTAMP:20120521T190638Z
LOCATION:$ical_location
SEQUENCE:0
BEGIN:VALARM
TRIGGER:-PT1H
DESCRIPTION:Event reminder
ACTION:DISPLAY
END:VALARM
END:VEVENT
END:VCALENDAR
EOICAL
$ical_data = encode_base64($ical_data);
my $reply = '"Your Name" <you@yourdomain.com>';
my $from = $reply;
my $subject = "Abholung vom 1.6.2012, 21:00";
my $body = "This is a test :-) Corrected Version! You really have to pay attention to the line endings between the different headers!\n\tda maaki";
my $boundary = "=====" . time() . "=====";
foreach my $to (@recipients) {
my $result;
eval {
local $SIG{__DIE__};
$result = open SENDMAIL, "| $mailprog";
};
if ($@) {
die $@ unless $@ =~ /Insecure directory/;
delete $ENV{PATH};
$result = open SENDMAIL, "| $mailprog";
}
die "Can't open mailprog [$mailprog]\n" unless $result;
my $data = <<"EOMAIL";
MIME-Version: 1.0
From: $from
To: $to
Reply-to: $reply
Subject: $subject
Content-Type = multipart/mixed; boundary="$boundary"
--$boundary
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
$body
--$boundary
Content-Disposition: attachment;
Content-Type: text/calendar filename="$ical_file_name"
Content-Transfer-Encoding: base64
$ical_data
--$boundary--
EOMAIL
print SENDMAIL $data or die "write to sendmail pipe: $!";
close SENDMAIL or die "Closing of SENDMAIL failed: $!";
}
__END__