package Mailer;
use Email::Address;
+use Encode;
use SL::Common;
use SL::MIME;
$num_sent++;
my $boundary = time() . "-$$-${num_sent}";
$boundary = "LxOffice-$self->{version}-$boundary";
- my $domain = $self->{from};
+ my $domain = $self->recode($self->{from});
$domain =~ s/(.*?\@|>)//g;
my $msgid = "$boundary\@$domain";
my $form = $main::form;
my $myconfig = \%main::myconfig;
- my $email = $myconfig->{email};
+ my $email = $self->recode($myconfig->{email});
$email =~ s/[^\w\.\-\+=@]//ig;
my %temp_form = ( %{ $form }, 'myconfig_email' => $email );
foreach my $item (qw(to cc bcc)) {
next unless ($self->{$item});
+ $self->{$item} = $self->recode($self->{$item});
$self->{$item} =~ s/\</</g;
$self->{$item} =~ s/\$<\$/</g;
$self->{$item} =~ s/\>/>/g;
$self->{$item} =~ s/\$>\$/>/g;
}
+ $self->{from} = $self->recode($self->{from});
+
my $headers = '';
foreach my $item (qw(from to cc bcc)) {
next unless ($self->{$item});
}
}
- $headers .= sprintf("Subject: %s\n", $self->mime_quote_text($self->{subject}, 60));
+ $headers .= sprintf("Subject: %s\n", $self->mime_quote_text($self->recode($self->{subject}), 60));
print OUT qq|${headers}Message-ID: <$msgid>
X-Mailer: Lx-Office $self->{version}
print OUT qq|--${boundary}
Content-Type: $self->{contenttype}; charset="$self->{charset}"
-$self->{message}
+| . $self->recode($self->{message}) . qq|
|;
}
} else {
print OUT qq|Content-Type: $self->{contenttype}; charset="$self->{charset}"
-$self->{message}
+| . $self->recode($self->{message}) . qq|
|;
}
return $res;
}
+sub recode {
+ my $self = shift;
+ my $text = shift;
+
+ return $::locale->is_utf8 ? Encode::encode('utf-8-strict', $text) : $text;
+}
+
1;