Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d3ae61a2

Von Moritz Bunkus vor etwa 14 Jahren hinzugefügt

  • ID d3ae61a22bd97c6cbe9d7010591b2222b19bfde4
  • Vorgänger d6b20449
  • Nachfolger 72ad92fd

Text vor E-Mailversand von Perls internen Encoding nach UTF-8 encoden, sofern notwendig

Unterschiede anzeigen:

SL/Mailer.pm
31 31
package Mailer;
32 32

  
33 33
use Email::Address;
34
use Encode;
34 35

  
35 36
use SL::Common;
36 37
use SL::MIME;
......
103 104
  $num_sent++;
104 105
  my $boundary    = time() . "-$$-${num_sent}";
105 106
  $boundary       =  "LxOffice-$self->{version}-$boundary";
106
  my $domain      =  $self->{from};
107
  my $domain      =  $self->recode($self->{from});
107 108
  $domain         =~ s/(.*?\@|>)//g;
108 109
  my $msgid       =  "$boundary\@$domain";
109 110

  
110 111
  my $form        =  $main::form;
111 112
  my $myconfig    =  \%main::myconfig;
112 113

  
113
  my $email       =  $myconfig->{email};
114
  my $email       =  $self->recode($myconfig->{email});
114 115
  $email          =~ s/[^\w\.\-\+=@]//ig;
115 116

  
116 117
  my %temp_form   = ( %{ $form }, 'myconfig_email' => $email );
......
127 128

  
128 129
  foreach my $item (qw(to cc bcc)) {
129 130
    next unless ($self->{$item});
131
    $self->{$item} =  $self->recode($self->{$item});
130 132
    $self->{$item} =~ s/\&lt;/</g;
131 133
    $self->{$item} =~ s/\$<\$/</g;
132 134
    $self->{$item} =~ s/\&gt;/>/g;
133 135
    $self->{$item} =~ s/\$>\$/>/g;
134 136
  }
135 137

  
138
  $self->{from} = $self->recode($self->{from});
139

  
136 140
  my $headers = '';
137 141
  foreach my $item (qw(from to cc bcc)) {
138 142
    next unless ($self->{$item});
......
151 155
    }
152 156
  }
153 157

  
154
  $headers .= sprintf("Subject: %s\n", $self->mime_quote_text($self->{subject}, 60));
158
  $headers .= sprintf("Subject: %s\n", $self->mime_quote_text($self->recode($self->{subject}), 60));
155 159

  
156 160
  print OUT qq|${headers}Message-ID: <$msgid>
157 161
X-Mailer: Lx-Office $self->{version}
......
166 170
      print OUT qq|--${boundary}
167 171
Content-Type: $self->{contenttype}; charset="$self->{charset}"
168 172

  
169
$self->{message}
173
| . $self->recode($self->{message}) . qq|
170 174

  
171 175
|;
172 176
    }
......
223 227
  } else {
224 228
    print OUT qq|Content-Type: $self->{contenttype}; charset="$self->{charset}"
225 229

  
226
$self->{message}
230
| . $self->recode($self->{message}) . qq|
227 231
|;
228 232
  }
229 233

  
......
262 266
  return $res;
263 267
}
264 268

  
269
sub recode {
270
  my $self = shift;
271
  my $text = shift;
272

  
273
  return $::locale->is_utf8 ? Encode::encode('utf-8-strict', $text) : $text;
274
}
275

  
265 276
1;
266 277

  

Auch abrufbar als: Unified diff