Revision 53c42274
Von Tamino Steinert vor 12 Monaten hinzugefügt
SL/IMAPClient.pm | ||
---|---|---|
176 | 176 |
sub _create_email_journal { |
177 | 177 |
my ($self, $email, $email_import, $uid, $folder_string, $folder_uidvalidity, $params) = @_; |
178 | 178 |
|
179 |
if ($email->content_type) { # decode header |
|
180 |
my $charset = $email->content_type =~ /charset="(.+)"/ ? $1 : undef; |
|
181 |
if ($charset) { |
|
182 |
map { $email->header_str_set($_ => decode($charset, $email->header($_))) } |
|
183 |
$email->header_names; |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
179 | 187 |
my @email_parts = $email->parts; # get parts or self |
180 | 188 |
my $text_part = $email_parts[0]; |
181 |
my $body = $text_part->body;
|
|
189 |
my $body_text = $text_part->body_str;
|
|
182 | 190 |
|
191 |
my %header_map = map { $_ => $email->header_str($_) } $email->header_names; |
|
192 |
# We need to store the Content-Type header for the text part |
|
193 |
$header_map{'Content-Type'} = $text_part->content_type; |
|
183 | 194 |
my $header_string = join "\r\n", |
184 |
(map { $_ . ': ' . $email->header($_) } $email->header_names);
|
|
195 |
(map { $_ . ': ' . $header_map{$_} } keys %header_map);
|
|
185 | 196 |
|
186 |
my $date = $self->_parse_date($email->header('Date')); |
|
197 |
my $date = $self->_parse_date($email->header_str('Date'));
|
|
187 | 198 |
|
188 |
my $recipients = $email->header('To'); |
|
189 |
$recipients .= ', ' . $email->header('Cc') if ($email->header('Cc'));
|
|
190 |
$recipients .= ', ' . $email->header('Bcc') if ($email->header('Bcc'));
|
|
199 |
my $recipients = $email->header_str('To');
|
|
200 |
$recipients .= ', ' . $email->header_str('Cc') if ($email->header_str('Cc'));
|
|
201 |
$recipients .= ', ' . $email->header_str('Bcc') if ($email->header_str('Bcc'));
|
|
191 | 202 |
|
192 | 203 |
my @attachments = (); |
193 | 204 |
$email->walk_parts(sub { |
... | ... | |
213 | 224 |
uid => $uid, |
214 | 225 |
status => 'imported', |
215 | 226 |
extended_status => '', |
216 |
from => $email->header('From') || '', |
|
227 |
from => $email->header_str('From') || '',
|
|
217 | 228 |
recipients => $recipients, |
218 | 229 |
sent_on => $date, |
219 |
subject => $email->header('Subject') || '', |
|
220 |
body => $body, |
|
230 |
subject => $email->header_str('Subject') || '',
|
|
231 |
body => $body_text,
|
|
221 | 232 |
headers => $header_string, |
222 | 233 |
attachments => \@attachments, |
223 | 234 |
%$params, |
Auch abrufbar als: Unified diff
SL::IMAPClient: Nutze das richtige Encoding für Header und Body