| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Kolab::Mailer; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
## |
|
4
|
|
|
|
|
|
|
## Copyright (c) 2003 Code Fusion cc |
|
5
|
|
|
|
|
|
|
## |
|
6
|
|
|
|
|
|
|
## Writen by Stuart Bingė |
|
7
|
|
|
|
|
|
|
## |
|
8
|
|
|
|
|
|
|
## This program is free software; you can redistribute it and/or |
|
9
|
|
|
|
|
|
|
## modify it under the terms of the GNU General Public License as |
|
10
|
|
|
|
|
|
|
## published by the Free Software Foundation; either version 2, or |
|
11
|
|
|
|
|
|
|
## (at your option) any later version. |
|
12
|
|
|
|
|
|
|
## |
|
13
|
|
|
|
|
|
|
## This program is distributed in the hope that it will be useful, |
|
14
|
|
|
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16
|
|
|
|
|
|
|
## General Public License for more details. |
|
17
|
|
|
|
|
|
|
## |
|
18
|
|
|
|
|
|
|
## You can view the GNU General Public License, online, at the GNU |
|
19
|
|
|
|
|
|
|
## Project's homepage; see . |
|
20
|
|
|
|
|
|
|
## |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
23947
|
use 5.008; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
36
|
|
|
23
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
24
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
34
|
|
|
25
|
1
|
|
|
1
|
|
8047
|
use Kolab; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use MIME::Entity; |
|
27
|
|
|
|
|
|
|
use MIME::Body; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
require Exporter; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
34
|
|
|
|
|
|
|
'all' => [ qw( |
|
35
|
|
|
|
|
|
|
&sendMultipart |
|
36
|
|
|
|
|
|
|
&sendText |
|
37
|
|
|
|
|
|
|
) |
|
38
|
|
|
|
|
|
|
] ); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our $VERSION = sprintf('%d.%02d', q$Revision: 1.1.1.1 $ =~ /(\d+)\.(\d+)/); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub sendMultipart |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
|
|
|
|
|
|
my $from = shift || ''; |
|
51
|
|
|
|
|
|
|
my $to = shift || ''; |
|
52
|
|
|
|
|
|
|
my $subj = shift || ''; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $mesg = MIME::Entity->build( |
|
55
|
|
|
|
|
|
|
From => $from, |
|
56
|
|
|
|
|
|
|
To => $to, |
|
57
|
|
|
|
|
|
|
Subject => $subj, |
|
58
|
|
|
|
|
|
|
Type => "multipart/mixed" |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my (@stats, $data); |
|
62
|
|
|
|
|
|
|
while (my $file = shift) { |
|
63
|
|
|
|
|
|
|
@stats = stat($file); |
|
64
|
|
|
|
|
|
|
seek($file, 0, 0); |
|
65
|
|
|
|
|
|
|
read($file, $data, $stats[7]); |
|
66
|
|
|
|
|
|
|
Kolab::log('M', 'Read ' . $stats[7] . ' bytes, data = ' . $data, KOLAB_DEBUG); |
|
67
|
|
|
|
|
|
|
$mesg->attach(Data => $data); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
open(SENDMAIL, '|' . $Kolab::config{'prefix'} . '/sbin/sendmail -oi -t -odq'); |
|
71
|
|
|
|
|
|
|
$mesg->print(\*SENDMAIL); |
|
72
|
|
|
|
|
|
|
close(SENDMAIL); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub sendText |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
|
|
|
|
|
|
my $from = shift || ''; |
|
78
|
|
|
|
|
|
|
my $to = shift || ''; |
|
79
|
|
|
|
|
|
|
my $subj = shift || ''; |
|
80
|
|
|
|
|
|
|
my $text = shift || ''; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $mesg = MIME::Entity->build( |
|
83
|
|
|
|
|
|
|
From => $from, |
|
84
|
|
|
|
|
|
|
To => $to, |
|
85
|
|
|
|
|
|
|
Subject => $subj, |
|
86
|
|
|
|
|
|
|
Data => $text, |
|
87
|
|
|
|
|
|
|
); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
open(SENDMAIL, '|' . $Kolab::config{'prefix'} . '/sbin/sendmail -oi -t -odq'); |
|
90
|
|
|
|
|
|
|
$mesg->print(\*SENDMAIL); |
|
91
|
|
|
|
|
|
|
close(SENDMAIL); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
|
95
|
|
|
|
|
|
|
__END__ |