way has asked for the wisdom of the Perl Monks concerning the following question:

Hello Fellows

I have a little question, how do i do to send an email encoded in iso-8859-1 (aka latin1) with MIME::Lite.

I have not problem encoded the body, but MIME::Lite don't encode the subject and when I parse it with Mail::Message I receive this error:

WARNING: Illegal character in field name From test@test.com Wed Jan 28 09</>

Becouse the From field haven't no-ascii characters i guess that the problem come from the subject

I'm correct?, totally wrong?, what's do you think?

This's the code:

my $msg = MIME::Lite->new( From => 'test@test.com', To => 'test@test.com', Subject => '!Hey‘ This is a αινσϊδλοφόρΡ mail!', Type => 'text/html', Encoding => 'quoted-printable' Data => q{ <h1>αινσϊδλοφόρΡ</h1> } ); $msg->attr('content-type.charset' => 'ISO-8859-1' ); $msg->send;

Cheers!

Replies are listed 'Best First'.
Re: Send latin1 email with MIME::Lite
by Anonymous Monk on Jan 28, 2009 at 17:18 UTC
    Mail::Message::Field::Full
    Warning: Illegal character in field name $name

    A new field is being created which does contain characters not permitted by the RFCs. Using this field in messages may break other e-mail clients or transfer agents, and therefore mutulate or extinguish your message.

      Ok, I see, but if I do something like this:

      my $msg = MIME::Lite->new( From => 'test@test.com', To => 'test@test.com', Subject => Mail::Message::Field::Full->new(charset => 'iso-8859-1 +')->encode('!Hey‘ This is a αινσϊδλοφόρΡ mail!'), Type => 'text/html', Encoding => 'quoted-printable' Data => q{ <h1>αινσϊδλοφόρΡ</h1> } ); $msg->attr('content-type.charset' => 'ISO-8859-1' ); $msg->send;

      still not work becouse encode the subject to us-ascii.

      And the main question, can MIME::Lite do this automatically?

      Thank you so much