+
+ push @{ $self->{headers} }, ( ucfirst($item) => join(', ', @header_addresses) ) if @header_addresses;
+ }
+}
+
+sub _create_attachment_part {
+ my ($self, $attachment) = @_;
+
+ my %attributes = (
+ disposition => 'attachment',
+ encoding => 'base64',
+ );
+
+ my $attachment_content;
+ my $file_id = 0;
+ my $email_journal = $::instance_conf->get_email_journal;
+
+ if (ref($attachment) eq "HASH") {
+ $attributes{filename} = $attachment->{name};
+ $file_id = $attachment->{id} || '0';
+ $attributes{content_type} = $attachment->{type} || 'application/pdf';
+ $attachment_content = $attachment->{content};
+ $attachment_content = eval { read_file($attachment->{path}) } if !$attachment_content;
+
+ } else {
+ $attributes{filename} = $attachment;
+ $attributes{filename} =~ s:.*\Q$self->{fileid}\E:: if $self->{fileid};
+ $attributes{filename} =~ s:.*/::g;
+
+ my $application = ($attachment =~ /(^\w+$)|\.(html|text|txt|sql)$/) ? 'text' : 'application';
+ $attributes{content_type} = File::MimeInfo::Magic::magic($attachment);
+ $attributes{content_type} ||= "${application}/$self->{format}" if $self->{format};
+ $attributes{content_type} ||= 'application/octet-stream';
+ $attachment_content = eval { read_file($attachment) };
+ }
+
+ return undef if $email_journal > 1 && !defined $attachment_content;
+
+ $attachment_content ||= ' ';
+ $attributes{charset} = $self->{charset} if $self->{charset} && ($attributes{content_type} =~ m{^text/});
+
+ my $ent;
+ if ( $attributes{content_type} eq 'message/rfc822' ) {
+ $ent = Email::MIME->new($attachment_content);
+ } else {
+ $ent = Email::MIME->create(
+ attributes => \%attributes,
+ body => $attachment_content,
+ );