Leser: 21
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
#!/usr/bin/perl
use strict;
use MIME::Lite;
use Time::localtime;
use MIME::Words qw(:all);
use Encode;
my $mailtext="";
mail();
sub mail
{
my $sendmail = "/usr/sbin/sendmail -t";
my $from = "myadress@email.com";
my $reply_to = "myadress@email.com";
my $subject = "Subject ü ä ö";
my $mail_message = "This is a text with ü ä and ö";
#Subject encoding
utf8::decode($subject);
# Create new mail
my $msg = MIME::Lite->new
(
Subject => $subject,
From => $from,
To => 'mymail@mail.com',
Type => 'multipart/mixed',
Charset => 'utf-8'
);
# Mailtext
$mailtext=$mail_message;
$msg->attach
(
Type => 'TEXT',
Data => $mailtext
);
# Send mail
MIME::Lite->send("sendmail", $sendmail);
$msg->send;
}
exit;
1
2
3
4
5
6
7
my $part = MIME::Lite->new(
Type => 'TEXT',
Data => $mailtext,
);
$part->attr('content-type.charset' => 'UTF-8');
$msg->attach($part);