X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FMailer.pm;h=3805fb40cbdffd701adcd69492e435273a4e848e;hb=daaac66a83e3dbdcc910731a1695e7e59b9cbbc6;hp=dc6002b42eb6a12b8df9238427c0607f6e7d4941;hpb=8fec2dc1a8d85554b23c6333bac430d6004a6aed;p=kivitendo-erp.git diff --git a/SL/Mailer.pm b/SL/Mailer.pm index dc6002b42..3805fb40c 100644 --- a/SL/Mailer.pm +++ b/SL/Mailer.pm @@ -38,6 +38,11 @@ use strict; my $num_sent = 0; +my %mail_delivery_modules = ( + sendmail => 'SL::Mailer::Sendmail', + smtp => 'SL::Mailer::SMTP', +); + sub new { my ($type, %params) = @_; my $self = { %params }; @@ -54,7 +59,7 @@ sub _create_driver { myconfig => \%::myconfig, ); - my $module = ($::lx_office_conf{mail_delivery}->{method} || 'smtp') ne 'smtp' ? 'SL::Mailer::Sendmail' : 'SL::Mailer::SMTP'; + my $module = $mail_delivery_modules{ $::lx_office_conf{mail_delivery}->{method} }; eval "require $module" or return undef; return $module->new(%params); @@ -236,12 +241,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( @@ -250,7 +261,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} || [] });