projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Finanzbuchhaltung: schönere »…verbucht«-Meldungen via Flash
[kivitendo-erp.git]
/
SL
/
Mailer.pm
diff --git
a/SL/Mailer.pm
b/SL/Mailer.pm
index
67f5fdd
..
eb94ae3
100644
(file)
--- a/
SL/Mailer.pm
+++ b/
SL/Mailer.pm
@@
-17,7
+17,8
@@
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
#======================================================================
package Mailer;
#======================================================================
package Mailer;
@@
-38,6
+39,11
@@
use strict;
my $num_sent = 0;
my $num_sent = 0;
+my %mail_delivery_modules = (
+ sendmail => 'SL::Mailer::Sendmail',
+ smtp => 'SL::Mailer::SMTP',
+);
+
sub new {
my ($type, %params) = @_;
my $self = { %params };
sub new {
my ($type, %params) = @_;
my $self = { %params };
@@
-54,7
+60,7
@@
sub _create_driver {
myconfig => \%::myconfig,
);
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);
eval "require $module" or return undef;
return $module->new(%params);
@@
-121,26
+127,25
@@
sub _create_address_headers {
sub _create_attachment_part {
my ($self, $attachment) = @_;
sub _create_attachment_part {
my ($self, $attachment) = @_;
- my $source_file_name;
-
my %attributes = (
disposition => 'attachment',
encoding => 'base64',
);
my %attributes = (
disposition => 'attachment',
encoding => 'base64',
);
+ my $attachment_content;
+
if (ref($attachment) eq "HASH") {
$attributes{filename} = $attachment->{name};
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;
} 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';
return undef if !defined $attachment_content;
my $application = ($attachment =~ /(^\w+$)|\.(html|text|txt|sql)$/) ? 'text' : 'application';
@@
-237,12
+242,18
@@
sub _all_recipients {
sub _store_in_journal {
my ($self, $status, $extended_status) = @_;
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';
$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(
my $part = $self->_create_attachment_part($_);
if ($part) {
SL::DB::EmailJournalAttachment->new(
@@
-251,7
+262,7
@@
sub _store_in_journal {
content => $part->body,
)
}
content => $part->body,
)
}
- } @{ $self->{attachments} || [] };
+ } @{ $self->{attachments} || [] }
if $journal_enable > 1
;
my $headers = join "\r\n", (bundle_by { join(': ', @_) } 2, @{ $self->{headers} || [] });
my $headers = join "\r\n", (bundle_by { join(': ', @_) } 2, @{ $self->{headers} || [] });