So here's the patch to be able to force the email charset
no matter the frontend charset is. Please be aware that
this was not thoroughly tested and is a rude hack (that means
it completely lacks of design).

EncodeObject probably should be fixed instead.

It seems to work nevertheless, and doesn't choke if the
mail would contain characters not possible to represent in
the output charset (due to FB_HTMLCREF).

Set   $Self->{EmailCharsetForced} = 'iso-8859-2';  (or
whatever your email charset preference is) in Config.pm for
the best effects.

And say a curse on bill gates today, and a blessing on martin ;)


--- ./System/Email/Sendmail.pm-20041011 2004-10-11 16:42:59.000000000 +0200
+++ ./System/Email/Sendmail.pm 2004-10-11 17:13:20.000000000 +0200
@@ -64,7 +64,11 @@
# send mail
if (open( MAIL, "| $Self->{Sendmail} $Arg")) {
# set handle to binmode if utf-8 is used
- $Self->{EncodeObject}->SetIO(\*MAIL);
+ if( !defined( $Param{Charset} ) || $Param{Charset} =~ /utf-?8/i ) {
+ # if Charset is not defined, act on DefaultCharset
+ # if it is utf8, then go on and hope that DefaultCharset it utf8, too :-@
+ $Self->{EncodeObject}->SetIO(\*MAIL);
+ }
print MAIL ${$Param{Header}};
print MAIL "\n";
print MAIL ${$Param{Body}};
--- ./System/Ticket/Article.pm-20041011 2004-10-11 13:05:02.000000000 +0200
+++ ./System/Ticket/Article.pm 2004-10-11 17:14:48.000000000 +0200
@@ -15,6 +15,7 @@
use Mail::Internet;
use Kernel::System::StdAttachment;
use Kernel::System::Crypt;
+use Encode;


use vars qw($VERSION);
$VERSION = '$Revision: 1.70.2.1 $';
@@ -1178,6 +1179,16 @@
$Param{$_} = encode_mimewords($Param{$_}, Charset => $Charset) || '';
}
}
+ # encode if email charset forced
+ if( defined($Self->{ConfigObject}->Get('EmailCharsetForced')) ) {
+ #$Self->{EncodeObject} = Kernel::System::Encode->new( ConfigObject => $Self->{ConfigObject} );
+ #my $newbody = $Self->{EncodeObject}->Convert(
+ # Text => $Param{Body},
+ # From => $Charset,
+ # To => $Self->{ConfigObject}->Get('EmailCharsetForced') );
+ $Param{Body} = Encode::encode( $Self->{ConfigObject}->Get('EmailCharsetForced'), $Param{Body}, Encode::FB_HTMLCREF );
+ $Charset = $Self->{ConfigObject}->Get('EmailCharsetForced');
+ }
# check bcc
if ($Self->{SendmailBcc}) {
$Param{Bcc} .= ", $Self->{SendmailBcc}";
@@ -1486,6 +1497,7 @@
Subject => $Param{Subject},
Header => $head->as_string(),
Body => $Entity->body_as_string(),
+ Charset => $Charset,
)) {
# write article to fs
if (!$Self->ArticleWritePlain(
@@ -1573,6 +1585,7 @@
Bcc => $Self->{SendmailBcc},
Header => $HeaderObject->as_string(),
Body => $BodyAsSting,
+ # Charset => $Charset,
)) {
return;
}
@@ -2087,7 +2100,7 @@
To => $GetParam{From},
Cc => $Cc,
RealName => $Param{Realname},
- Charset => $Param{Charset},
+ Charset => $Self->{ConfigObject}->Get('EmailCharsetForced') || $Param{Charset},
Subject => $Subject,
UserID => $Param{UserID},
Body => $Param{Body},
--- ./System/Email.pm-20041011 2004-10-11 16:59:17.000000000 +0200
+++ ./System/Email.pm 2004-10-11 17:00:06.000000000 +0200
@@ -212,6 +212,7 @@
ToArray => [EMAIL PROTECTED],
Header => \$Param{Header},
Body => \$Param{Body},
+ Charset => \$Param{Charset},
);
}





-- Now using M2, Opera's e-mail client: http://www.opera.com/m2/

_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev

Reply via email to