X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FMailer.pm;h=6536850581a0b611669c39c8e5e697a5b1a799c1;hb=4f43ec85816b8f5c9031ff35adfa9e0d33c4306f;hp=67f5fdd2ffee88e45942fa6a41ec2995565074ca;hpb=24ab7ec0bfb052edce7a3c7a6e37c151f9cd6a04;p=kivitendo-erp.git diff --git a/SL/Mailer.pm b/SL/Mailer.pm index 67f5fdd2f..653685058 100644 --- a/SL/Mailer.pm +++ b/SL/Mailer.pm @@ -121,26 +121,25 @@ sub _create_address_headers { sub _create_attachment_part { my ($self, $attachment) = @_; - my $source_file_name; - my %attributes = ( disposition => 'attachment', encoding => 'base64', ); + my $attachment_content; + if (ref($attachment) eq "HASH") { $attributes{filename} = $attachment->{name}; - $source_file_name = $attachment->{filename}; + $attachment_content = $attachment->{content} // eval { read_file($attachment->{filename}) }; } else { # strip path $attributes{filename} = $attachment; $attributes{filename} =~ s:.*\Q$self->{fileid}\E:: if $self->{fileid}; $attributes{filename} =~ s:.*/::g; - $source_file_name = $attachment; + $attachment_content = eval { read_file($attachment) }; } - my $attachment_content = eval { read_file($source_file_name) }; return undef if !defined $attachment_content; my $application = ($attachment =~ /(^\w+$)|\.(html|text|txt|sql)$/) ? 'text' : 'application'; @@ -237,12 +236,18 @@ sub _all_recipients { sub _store_in_journal { my ($self, $status, $extended_status) = @_; + my $journal_enable = $::instance_conf->get_email_journal; + + return if $journal_enable == 0; + $status //= $self->{driver}->status if $self->{driver}; $status //= 'failed'; $extended_status //= $self->{driver}->extended_status if $self->{driver}; $extended_status //= 'unknown error'; - my @attachments = grep { $_ } map { + my @attachments; + + @attachments = grep { $_ } map { my $part = $self->_create_attachment_part($_); if ($part) { SL::DB::EmailJournalAttachment->new( @@ -251,7 +256,7 @@ sub _store_in_journal { content => $part->body, ) } - } @{ $self->{attachments} || [] }; + } @{ $self->{attachments} || [] } if $journal_enable > 1; my $headers = join "\r\n", (bundle_by { join(': ', @_) } 2, @{ $self->{headers} || [] });