+ @attachments = grep { $_ } map {
+ my $part = $self->_create_attachment_part($_);
+ if ($part) {
+ SL::DB::EmailJournalAttachment->new(
+ name => $part->filename,
+ mime_type => $part->content_type,
+ content => $part->body,
+ )
+ }
+ } @{ $self->{attachments} || [] } if $journal_enable > 1;
+
+ my $headers = join "\r\n", (bundle_by { join(': ', @_) } 2, @{ $self->{headers} || [] });
+
+ SL::DB::EmailJournal->new(
+ sender => SL::DB::Manager::Employee->current,
+ from => $self->{from} // '',
+ recipients => join(', ', $self->_all_recipients),
+ subject => $self->{subject} // '',
+ headers => $headers,
+ body => $self->{message} // '',
+ sent_on => DateTime->now_local,
+ attachments => \@attachments,
+ status => $status,
+ extended_status => $extended_status,
+ )->save;