Leser: 1
![]() |
|< 1 2 3 >| | ![]() |
26 Einträge, 3 Seiten |
$b = "--=_".substr(pack('u', ('Mail'.'Name')), 0, 24);
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
package Sources::Mime;
use strict;
use warnings;
use MIME::Lite;
use Sources::Vars;
use Sources::Mail;
use vars qw(@ISA);
@ISA = qw( MIME::Lite );
sub as_smtpstring
{
my ($self) = @_;
my $buf = [];
my $io = (wrap MIME::Lite::IO_ScalarArray $buf);
$self->replace('Message-ID' => Sources::Mail::build_message_id($self->get('From')));
$self->replace('X-Mailer' => Sources::Vars::X_MAILER);
$self->attr('MIME-Version' => '1.0');
### Create a safe head:
my @fields = grep { $_->[0] ne 'bcc' } @{$self->fields};
my $header = $self->fields_as_string(\@fields);
$io->print($header, "\n");
$self->print_body($io);
join '', @$buf;
}
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
my $msg = Sources::Mime->build(
From => $mime_from,
To => $mime_to,
Cc => $mime_cc,
Bcc => $mime_bcc,
Subject => $subject,
Type => "$type; charset=\"$charset\"",
Encoding => 'quoted-printable',
Data => $text);
my $mime_types = Sources::Global::load_inifile('./mime.types');
foreach my $fileattach (@attachs)
{
my $nname = Sources::Global::get_filename($fileattach);
$nname =~ s!-....$!!;
my $ext = lc(Sources::Global::get_fileextension($nname));
my $type = $mime_types->{$ext} || 'Unknown';
$msg->attach(
Type => $type,
Path => $fileattach,
Filename => $nname,
Disposition => 'attachment');
}
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
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI qw(:standard);
use CGI::Carp qw/fatalsToBrowser/;
use MIME::Lite;
my $empfaenger = 'dubu@localhost';
my $sender = 'apache@localhost';
print header();
print start_html('Beispiel Datei empfangen und per Mail versenden');
print h1('Beispiel Datei empfangen und per Mail versenden'),
p('Bitte eine Datei auswaehlen und mit dem Abschicken-Button hochschicken'),
start_multipart_form(),
"Dateiname:",
filefield('filename','',45),
submit('Submit','Abschicken'),
endform;
# Formulardaten bearbeiten, wenn vorhanden
if (my $file = param('filename')) {
my $tmpfile=tmpFileName($file);
my $mimetype = uploadInfo($file)->{'Content-Type'} || '';
print hr(),
h2("Dateiname: $file"),
h4("abgelegt als: $tmpfile"),
h4("MIME Type:",em($mimetype));
## Date als Mail versenden
# Erst der Mail-Header
my $msg = MIME::Lite->new (
From => $sender,
To => $empfaenger,
Subject => "Datei $file",
Type => 'multipart/mixed',
);
# Dann der begleitende Text
$msg->attach (
Type => 'TEXT',
Data => "Hier die Datei, versendet durch den Webserver (PID $$)",
);
# Dann das Attachment selber
$msg->attach (
Type => $mimetype,
Path => $tmpfile,
Filename => $file,
Disposition => 'attachment',
);
# TEST-AUSGABE im Browser (Vorsicht bei grossen Dateien!)
# print "<pre>\n", $msg->as_string, "\n</pre>\n";
# Message senden (default: sendmail benutzen, siehe Doku)
if ($msg->send()) {
print p(qq{<font color="green">Datei $file an $empfaenger verschickt.</font>});
} else {
print p('<font color="red">Sorry, keine Moeglichkeit Mails zu versenden!</font>');
}
}
print hr(),
end_html;
![]() |
|< 1 2 3 >| | ![]() |
26 Einträge, 3 Seiten |