my $smtp;
my $errormsg;
my $boundary = 'frontier-'.$domain;
for (my $i=1;$i<=50;$i++) {
$errormsg = '';
$betreff = "Test $i mit großen Anhang";
IO::Socket::SSL::set_defaults(SSL_verify_mode => 0);
if(!($smtp = Net::SMTP::SSL->new(Host => 'smtp.strato.de',
Hello => $domain,
Timeout => 10,
Port => 465)))
{
$errormsg = "Could not connect to SMTP Server: smtp.strato.de
";
}
else {
my $error = $smtp->auth('webmaster@'.$domain,$pw) ;
if (! $error) {
$errormsg = 'Cannot authenticate as user webmaster@'.$domain." and/or bad Password for Email - Error $error - Check System Settings
";
}
}
if ($errormsg eq '') {
$smtp->mail($emfrom);
if (!($smtp->recipient($to))) {
$errormsg .= "Ungültige Email-Adresse: $to
".$smtp->message().'
';
}
$smtp->data();
$smtp->datasend("To: $emto\n");
$smtp->datasend("From: $emfrom\n");
$smtp->datasend('Subject: '.umlaut($betreff)."\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-type: multipart/mixed; boundary=\"$boundary\"\n");
$smtp->datasend("\n");
$smtp->datasend("--$boundary\n");
$smtp->datasend("Content-type: text/html\n");
$smtp->datasend("\n");
$smtp->datasend("$emtext\n");
if (-f $verz.$anhang) {
my $mimetype = 'application/zip';
if (lc($anhang) =~ /\.pdf$/) {$mimetype = 'application/pdf';}
elsif (lc($anhang) =~ /\.gif$/) {$mimetype = 'image/gif';}
elsif (lc($anhang) =~ /\.htm$|\.html$/) {$mimetype = 'text/html';}
elsif (lc($anhang) =~ /\.jpg$|\.jpeg$|\.jpe$/) {$mimetype = 'image/jpeg';}
elsif (lc($anhang) =~ /\.rtf$/) {$mimetype = 'application/rtf';}
elsif (lc($anhang) =~ /\.txt$/) {$mimetype = 'text/plain';}
elsif (lc($anhang) =~ /\.xls$/) {$mimetype = 'text/msexcel';}
elsif (lc($anhang) =~ /\.csv$/) {$mimetype = 'text/tab-separated-values';}
elsif (lc($anhang) =~ /\.tif$|\.tiff$/) {$mimetype = 'image/tiff';}
elsif (lc($anhang) =~ /\.png$/) {$mimetype = 'image/png';}
elsif (lc($anhang) =~ /\.avi$/) {$mimetype = 'video/ms-video';}
elsif (lc($anhang) =~ /\.wav$/) {$mimetype = 'audio/x-wav';}
elsif (lc($anhang) =~ /\.zip$/) {$mimetype = 'application/zip';}
$smtp->datasend("\n--$boundary\n");
$smtp->datasend("Content-Type: $mimetype; name=\"$anhang\"\n");
$smtp->datasend("Content-Transfer-Encoding: base64\n");
$smtp->datasend("Content-Disposition: attachment; filename=\"$anhang\"\n");
$smtp->datasend("\n");
open(DAT, "$verz$anhang") || die("Could not open $verz$anhang!");
binmode(DAT);
while (read(DAT, my $bindata, 72*57)) {
my $buf = &encode_base64( $bindata );
$smtp->datasend($buf);
}
close(DAT);
}
$smtp->datasend("\n--$boundary--\n");
$smtp->datasend("\n");
$smtp->dataend();
$smtp->quit();
if ($errormsg eq '' && !$smtp->ok) {
$errormsg .= $smtp->code()." ".$smtp->message()."
";
}
}
print "Email $i gesendet: $errormsg
";
}