Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 63dc98ee

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID 63dc98ee1d7bc23baa2567f2da7ad188f38d70d1
  • Vorgänger af131a46
  • Nachfolger 895ccd7f

SL::Mailer: Kosmetik für bessere Lesbarkeit (Alignment, Leerzeichen, Einrückung)

Unterschiede anzeigen:

SL/Mailer.pm
137 137
    Encoding     => 'base64',
138 138
  );
139 139

  
140
  my $file_id = 0;
141 140
  my $attachment_content;
141
  my $file_id       = 0;
142 142
  my $email_journal = $::instance_conf->get_email_journal;
143 143

  
144
  $main::lxdebug->message(LXDebug->DEBUG2(), "mail5 att=".$attachment." email_journal=". $email_journal." id=".$attachment->{id});
144
  $::lxdebug->message(LXDebug->DEBUG2(), "mail5 att=" . $attachment . " email_journal=" . $email_journal . " id=" . $attachment->{id});
145

  
145 146
  if (ref($attachment) eq "HASH") {
146 147
    $attributes{Path}     = $attachment->{path} || $attachment->{filename};
147 148
    $attributes{Filename} = $attachment->{name};
......
164 165
  }
165 166

  
166 167
  return undef if $email_journal > 1 && !defined $attachment_content;
167
  $attachment_content ||= ' ';
168
  $main::lxdebug->message(LXDebug->DEBUG2(), "mail6 mtype=".$attributes{Type}." path=".
169
                            $attributes{Path}." filename=".$attributes{Filename});
170 168

  
171
# $attributes{Charset}  = $self->{charset} if lc $application eq 'text' && $self->{charset};
169
  $attachment_content ||= ' ';
172 170
  $attributes{Charset}  = $self->{charset} if $self->{charset};
173 171

  
172
  $::lxdebug->message(LXDebug->DEBUG2(), "mail6 mtype=" . $attributes{Type} . " path=" . $attributes{Path} . " filename=" . $attributes{Filename});
173

  
174 174
  my $ent;
175 175
  if ( $attributes{Type} eq 'message/rfc822' ) {
176
    my $fh = IO::File->new($attributes{Path}, "r");
177
    if (! defined $fh) {
178
      return undef;
179
    }
180
    $ent = $parser->parse($fh);
181
    undef $fh;
182
    my $head = $ent->head;
183
    $head->replace('Content-disposition','attachment; filename='.$attributes{Filename});
176
    my $fh = IO::File->new($attributes{Path}, "r") or return undef;
177
    $ent   = $parser->parse($fh);
178

  
179
    $ent->head->replace('Content-disposition','attachment; filename='.$attributes{Filename});
180

  
184 181
  } else {
185 182
    $ent = MIME::Entity->build(%attributes);
186 183
  }
184

  
187 185
  push @{ $self->{mail_attachments}} , SL::DB::EmailJournalAttachment->new(
188 186
    name      => $attributes{Filename},
189 187
    mime_type => $attributes{Type},
190 188
    content   => ( $email_journal > 1 ? $attachment_content : ' '),
191 189
    file_id   => $file_id,
192 190
  );
191

  
193 192
  return $ent;
194 193
}
195 194

  
196 195
sub _create_message {
197 196
  my ($self) = @_;
198 197

  
199
  push @{ $self->{headers} }, ('Type'    =>"multipart/mixed" );
200
  my  $top = MIME::Entity->build(@{$self->{headers}});
198
  push @{ $self->{headers} }, (Type => "multipart/mixed");
199

  
200
  my $top = MIME::Entity->build(@{$self->{headers}});
201

  
201 202
  if ($self->{message}) {
202
    $top->attach(Data => encode($self->{charset},$self->{message}),
203
                 Charset => $self->{charset},
204
                 Type => $self->{contenttype},
205
                 Encoding    => 'quoted-printable');
203
    $top->attach(
204
      Data     => encode($self->{charset},$self->{message}),
205
      Charset  => $self->{charset},
206
      Type     => $self->{contenttype},
207
      Encoding => 'quoted-printable',
208
    );
206 209
  }
207 210

  
208
  map { $top->add_part($self->_create_attachment_part($_)) } @{ $self->{attachments} || [] };
211
  $top->add_part($self->_create_attachment_part($_)) for @{ $self->{attachments} || [] };
212

  
209 213
  return $top;
210 214
}
211 215

  

Auch abrufbar als: Unified diff