From d0ebc49885ebb1bb8be33629f01233ef1aade037 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Fri, 18 Jan 2019 11:31:35 +0100 Subject: [PATCH] =?utf8?q?Erg=C3=A4nzung=20zu=20a3b8cfa7b7546=20(Mahnungen?= =?utf8?q?=20konfigurierbar=20machen)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - bessere Fehlerbehandlung -> send_mail läuft schon in einer Transaktion Von daher mit die hart aussteigen - Die Signatur des E-Mail-Versenders sollte dann auch zur E-Mail-Adresse passen, entsprechend backup vars erstellt vor dem Aufruf von Form::create_signature --- SL/DN.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/SL/DN.pm b/SL/DN.pm index 20b418421..5d0ee14a5 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -400,20 +400,22 @@ sub send_email { # without a recipient, we cannot send a mail if (!$ref || !$ref->{recipient}) { $main::lxdebug->leave_sub(); - $form->error($main::locale->text("No email recipient for customer #1 defined.", $ref->{name})); + die $main::locale->text("No email recipient for customer #1 defined.", $ref->{name}); } # without a sender we cannot send a mail # two cases: check mail from 1. current user OR 2. employee who created the invoice - my $from; + my ($from, $sign); if ($::instance_conf->get_dunning_creator eq 'current_employee') { $from = $myconfig->{email}; - $form->error($main::locale->text('No email for current user #1 defined.', $myconfig->{name})) unless $from; + die $main::locale->text('No email for current user #1 defined.', $myconfig->{name}) unless $from; } else { eval { $from = SL::DB::Manager::AuthUser->find_by(login => $ref->{invoice_employee_login})->get_config_value("email"); + $sign = SL::DB::Manager::AuthUser->find_by(login => $ref->{invoice_employee_login})->get_config_value("signature"); + die unless ($from); 1; - } or do { $form->error($main::locale->text('No email for user with login #1 defined.', $ref->{invoice_employee_login})) }; + } or die $main::locale->text('No email for user with login #1 defined.', $ref->{invoice_employee_login}); } my $template = SL::Template::create(type => 'PlainText', form => $form, myconfig => $myconfig); @@ -423,8 +425,10 @@ sub send_email { $mail->{to} = $ref->{recipient}; $mail->{subject} = $template->parse_block($ref->{email_subject}); $mail->{message} = $template->parse_block($ref->{email_body}); - + my $sign_backup = $::myconfig{signature}; + $::myconfig{signature} = $sign if $sign; $mail->{message} .= $form->create_email_signature(); + $::myconfig{signature} = $sign_backup if $sign; $mail->{message} =~ s/\r\n/\n/g; -- 2.20.1