Revision e8c2a3b8
Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt
SL/Mailer.pm | ||
---|---|---|
32 | 32 |
|
33 | 33 |
use Email::Address; |
34 | 34 |
use Encode; |
35 |
use File::Slurp; |
|
35 | 36 |
|
36 | 37 |
use SL::Common; |
37 | 38 |
use SL::MIME; |
... | ... | |
205 | 206 |
$filename =~ s/(.*\/|\Q$self->{fileid}\E)//g; |
206 | 207 |
} |
207 | 208 |
|
209 |
my $attachment_content = eval { read_file($attachment) }; |
|
210 |
if (!defined $attachment_content) { |
|
211 |
$main::lxdebug->leave_sub(); |
|
212 |
return "$attachment : $!"; |
|
213 |
} |
|
214 |
|
|
208 | 215 |
my $application = ($attachment =~ /(^\w+$)|\.(html|text|txt|sql)$/) ? "text" : "application"; |
209 | 216 |
my $content_type = SL::MIME->mime_type_from_ext($filename); |
210 | 217 |
$content_type = "${application}/$self->{format}" if (!$content_type && $self->{format}); |
211 | 218 |
$content_type ||= 'application/octet-stream'; |
212 | 219 |
|
213 |
open(IN, $attachment); |
|
214 |
if ($?) { |
|
215 |
$main::lxdebug->leave_sub(); |
|
216 |
return "$attachment : $!"; |
|
217 |
} |
|
218 |
|
|
219 | 220 |
# only set charset for attachements of type text. every other type should not have this field |
220 | 221 |
# refer to bug 883 for detailed information |
221 | 222 |
my $attachment_charset; |
... | ... | |
228 | 229 |
Content-Transfer-Encoding: BASE64 |
229 | 230 |
Content-Disposition: attachment; filename="$filename"\n\n|); |
230 | 231 |
|
231 |
my $msg = ""; |
|
232 |
while (<IN>) { |
|
233 |
; |
|
234 |
$msg .= $_; |
|
235 |
} |
|
236 |
$driver->print(encode_base64($msg)); |
|
237 |
|
|
238 |
close(IN); |
|
239 |
|
|
232 |
$driver->print(encode_base64($attachment_content)); |
|
240 | 233 |
} |
241 | 234 |
$driver->print(qq|--${boundary}--\n|); |
242 | 235 |
|
Auch abrufbar als: Unified diff
Attachments via File::Slurp einlesen, nicht manuell