Thread Probleme mit dem Mailversand nach Umstieg auf Perl 5.10 (26 answers)
Opened by Michael at 2010-12-16 12:07

GwenDragon
 2010-12-20 13:29
#143731 #143731
User since
2005-01-17
14536 Artikel
Admin1
[Homepage]
user image
Beispiel für ein Multipart-Mail mit HTML:

Code (perl): (dl )
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
my $html_filename = 'datei.html';

my $html;
if (open (my $htmlfh, '<', $html_filename)) {
  # Einlesen in einem Zug; siehe Perl Cookbook in <http://oreilly.com/catalog/cookbook/chapter/ch08.html>
  local $/ = undef;
  $html = <$htmlfh>;
  close($htmlfh);
} 
else {
  warn "Kann Datei $html_filename nicht oeffnen $!";
}

my $msg = MIME::Lite->new(
         To      =>'you@yourhost.com',
         Subject =>'Text und HTML mit Bildern!',
         Type    =>'multipart/alternative'
    );

### plain text
my $textpart = $msg->attach(Type => 'text/plain',
                         Data => [ 
                                   "Blah\n", 
                                   "Blubb\n"
                                 ]);
### HTML 
my $htmlpart = $msg->attach(Type => 'multipart/related');
$htmlpart->attach(Type => 'text/html',
               Data => [ $html ]);
$htmlpart->attach(Type => 'image/gif',
               Path => '/path/zu/bildern/Bild.gif',
               Id   => 'Bild1');

//EDIT: Habe Code auf Text + HTML umgestellt.
//EDIT2: doppeltes my entfernt

Du kannst das ja auf deine Bedürfnisse anpassen und weiter fragen, wenn es bei dir hakt.
Last edited: 2010-12-20 14:21:04 +0100 (CET)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread Probleme mit dem Mailversand nach Umstieg auf Perl 5.10