Revision d0ebc498
Von Jan Büren vor etwa 6 Jahren hinzugefügt
SL/DN.pm | ||
---|---|---|
400 | 400 |
# without a recipient, we cannot send a mail |
401 | 401 |
if (!$ref || !$ref->{recipient}) { |
402 | 402 |
$main::lxdebug->leave_sub(); |
403 |
$form->error($main::locale->text("No email recipient for customer #1 defined.", $ref->{name}));
|
|
403 |
die $main::locale->text("No email recipient for customer #1 defined.", $ref->{name});
|
|
404 | 404 |
} |
405 | 405 |
|
406 | 406 |
# without a sender we cannot send a mail |
407 | 407 |
# two cases: check mail from 1. current user OR 2. employee who created the invoice |
408 |
my $from;
|
|
408 |
my ($from, $sign);
|
|
409 | 409 |
if ($::instance_conf->get_dunning_creator eq 'current_employee') { |
410 | 410 |
$from = $myconfig->{email}; |
411 |
$form->error($main::locale->text('No email for current user #1 defined.', $myconfig->{name})) unless $from;
|
|
411 |
die $main::locale->text('No email for current user #1 defined.', $myconfig->{name}) unless $from;
|
|
412 | 412 |
} else { |
413 | 413 |
eval { |
414 | 414 |
$from = SL::DB::Manager::AuthUser->find_by(login => $ref->{invoice_employee_login})->get_config_value("email"); |
415 |
$sign = SL::DB::Manager::AuthUser->find_by(login => $ref->{invoice_employee_login})->get_config_value("signature"); |
|
416 |
die unless ($from); |
|
415 | 417 |
1; |
416 |
} or do { $form->error($main::locale->text('No email for user with login #1 defined.', $ref->{invoice_employee_login})) };
|
|
418 |
} or die $main::locale->text('No email for user with login #1 defined.', $ref->{invoice_employee_login});
|
|
417 | 419 |
} |
418 | 420 |
|
419 | 421 |
my $template = SL::Template::create(type => 'PlainText', form => $form, myconfig => $myconfig); |
... | ... | |
423 | 425 |
$mail->{to} = $ref->{recipient}; |
424 | 426 |
$mail->{subject} = $template->parse_block($ref->{email_subject}); |
425 | 427 |
$mail->{message} = $template->parse_block($ref->{email_body}); |
426 |
|
|
428 |
my $sign_backup = $::myconfig{signature}; |
|
429 |
$::myconfig{signature} = $sign if $sign; |
|
427 | 430 |
$mail->{message} .= $form->create_email_signature(); |
431 |
$::myconfig{signature} = $sign_backup if $sign; |
|
428 | 432 |
|
429 | 433 |
$mail->{message} =~ s/\r\n/\n/g; |
430 | 434 |
|
Auch abrufbar als: Unified diff
Ergänzung zu a3b8cfa7b7546 (Mahnungen konfigurierbar machen)
- bessere Fehlerbehandlung
> send_mail läuft schon in einer Transaktion
Die Signatur des E-Mail-Versenders sollte dann auch zur E-Mail-AdresseVon daher mit die hart aussteigen
passen, entsprechend backup vars erstellt vor dem Aufruf von Form::create_signature