Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

GT::Mail - can not change header_charset

Quote Reply
GT::Mail - can not change header_charset
I can not set header_charset header item to ISO-8859-2 in GT::Mail.

It always uses ISO-8859-1.


I tried several solutions,
Code:
my $mailer = GT::Mail->new(
'header_charset' => 'ISO-8859-2'
);
or
Code:
$mailer->args(
'header_charset' => 'ISO-8859-2'
);

but same result, header items are always encoded into ISO-8859-1.


Here is the whole code I use for testing:
Code:
use strict;
use warnings;

use Data::Dumper;
use GT::Mail;


# Get a new mailer object
my $mailer = GT::Mail->new(
# 'header_charset' => 'ISO-8859-2'
);

#$mailer->args(
# 'header_charset' => 'ISO-8859-2'
#);

$mailer->set('header_charset', 'ISO-8859-2');

# Input a text email string, with full header
my $mail_txt = q|To: Hisname <info@hisdomain.com>
From: Myname <me@mydomain.com>
Errors-To: Hisname <info@hisdomain.com>
Subject: Test email subject -

test email message body -
|;

# Parse the string
$mailer->parse($mail_txt);

# Flatten mail object into string
my $mail_result = $mailer->as_string();
print '$mail_result: ' . Dumper(\$mail_result) . "";


Is this a bug, or I do something wrong?

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...

Last edited by:

webmaster33: Dec 25, 2005, 3:06 PM
Quote Reply
Re: [webmaster33] GT::Mail - can not change header_charset In reply to
It does work, take a look at the header_charset usage in Links::send_email.

Adrian
Quote Reply
Re: [brewt] GT::Mail - can not change header_charset In reply to
It seems, in Links::send_email it's solved in a complex way, by rebuilding the header with different charset. I will try it that way, too.
But. Wouln't be possible to use a more simple & more logical GT::Mail API solution?


IMHO, this mailer API could be solved simply by input the mail charset:
Code:
my $mailer = GT::Mail->new(
'mail_charset' => 'ISO-8859-2'
);

or

Another way could be to allow to set different header charset for header and body:
Code:
my $mailer = GT::Mail->new(
'header_charset' => 'ISO-8859-1'
'body_charset' => 'ISO-8859-2'
);


I hope the GT::Mailer API will be changed to allow such charset definition.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [brewt] GT::Mail - can not change header_charset In reply to
I tested now with the example from Links::send_email.

Here is an example which is not working, even if used the example from Links::send_email.
The result is still badly ISO-8859-1. Check the header result.

Code:
use strict;
use warnings;

use Data::Dumper;
use GT::Mail;


# Input a text email string, with full header
my $mail_txt = q|To: <to@email.com>
From: <from@email.com>
Errors-To: <from@email.com>
Subject: Test -

Test -
|;


my $top = GT::Mail::Parse->new(
in_string => $mail_txt,
crlf => "\n",
headers_intact => 0,
)->parse();

my $charset = $top->delete('GT-Header-Charset');
$top->{header_charset} = $charset if $charset;

my $mail = new GT::Mail;
$mail->top_part($top);

# Flatten mail object into string
my $mail_result = $mail->as_string();
print '$mail_result: ' . Dumper(\$mail_result) . "";


Quote:
$mail_result: $VAR1 = \'From: =?ISO-8859-1?Q?=E1=E9=F3=F6=F5=FA=FC=FB=ED?= <from@email.com>
Subject: Test - =?ISO-8859-1?Q?=E1=E9=F3=F6=F5=FA=FC=FB=ED?=
To: =?ISO-8859-1?Q?=E1=E9=F3=F6=F5=FA=FC=FB=ED?= <to@email.com>
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Errors-To: =?ISO-8859-1?Q?=E1=E9=F3=F6=F5=FA=FC=FB=ED?= <from@email.com>
Mime-Version: 1.0

Test - =E1=E9=F3=F6=F5=FA=FC=FB=ED
';

What should I modify to get the desired effect, ISO-8859-2???

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...

Last edited by:

webmaster33: Jan 4, 2006, 9:39 AM