1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
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<br>"; } 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<br>"; } } if ($errormsg eq '') { $smtp->mail($emfrom); if (!($smtp->recipient($to))) { $errormsg .= "Ungültige Email-Adresse: $to<br>".$smtp->message().'<br>'; } $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()."<br>"; } } print "Email $i gesendet: $errormsg<br>"; }
QuoteSince Net::SMTP v1.28 (2014-10-08), Net::SMTP itself has support for SMTP over SSL, and also for STARTTLS. Use Net::SMTP, not Net::SMTP::SSL
1
2
3
4
if(!($smtp = Net::SMTP::SSL->new(Host => 'smtp.strato.de',
Hello => $domain,
Timeout => 10,
Port => 465)))
1
2
3
4
if(!($smtp = Net::SMTP->new(Host => 'smtp.strato.de',
Hello => $domain,
Timeout => 10,
SSL => 1)))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
#!/usr/bin/perl -w use strict; use Net::SMTP::SSL; use IO::Socket::SSL; use MIME::Base64 qw( encode_base64 ); my $host = 'smtp.strato.de'; my $domain = 'vereinslogistik.com'; my $emfrom = 'xxx@vereinslogistik.com'; my $emto = 'xxx@xxx.com'; my $pw = '*****'; my $verz = '../'; my $anhang = 'Datei mit 10Mb.jpg'; my $smtp; my $errormsg; my $betreff; 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 => $host, Hello => $domain, Timeout => 10, Port => 465))) { $errormsg = "Could not connect to SMTP Server: $host\n"; } 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\n"; } } if ($errormsg eq '') { $smtp->mail($emfrom); if (!($smtp->recipient($emto))) { $errormsg .= "Ungültige Email-Adresse: $emto\n".$smtp->message().'\n'; } $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("Test mit großen Anhang\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()."\n"; } } print "Email $i gesendet: $errormsg\n"; } #====================================# # Umlaute für Email-Header umsetzen # #====================================# sub umlaut { my $text = shift; $text =~ s/[=,;]//g; $text =~ s/[Ä]/=C4/g; $text =~ s/[ä]/=E4/g; $text =~ s/[Ö]/=D6/g; $text =~ s/[ö]/=F6/g; $text =~ s/[Ü]/=DC/g; $text =~ s/[ü]/=FC/g; $text =~ s/[ß]/=DF/g; $text =~ s/[ ]/_/g; if ($text =~ /=/) { $text = '=?ISO-8859-1?Q?'.$text.'?='; } else { $text =~ s/[_]/ /g; } return ($text); }
2017-07-17T18:01:14 b.altmannDies ist kein preisgünstiger Webspace, sondern ein eigener (managed) Server, der mir alleine gehört!
2017-07-18T10:02:57 b.altmannAuf die installierte Perl-Version habe ich leider keinen Einfluss, denn es handelt sich bei meinem Server um einen Managed Server. Da habe ich keine Rechte am System etwas zu installieren.
2017-07-20T10:47:54 b.altmannUnd ich weiß auch nicht ob ich Zugriff auf die notwendigen Verzeichnisse habe
2017-07-20T10:47:54 b.altmannund ob bei einem Software-Update durch STRATO nicht wieder alles entfernt werden würde.
2017-07-20T10:47:54 b.altmannDeshalb habe ich ja auch einen Managed Server gemietet.