Hi sync,

On Tuesday 18 Jan 2011 03:17:21 sync wrote:
> Greetings all,
> 
> I have to send emails through a smtp server, with Chinese  character
> encoding.
> 
> 
> In details , the  encoding of my  send mail is UTF-8, but the encoding of
> 
> others received is GB2321 , so it will apprears with "weird" characters.
> 
> 
> Does anyone has any working example or any suggestion please ?
> 

Maybe look into the Encode module and maybe try 
http://search.cpan.org/dist/Email-Sender/ instead of Mail-Sendmail.

Now a few comments on your code:

> Best Regards,
> 
> 
> My code is :
> 
>    1. #!/usr/bin/perl
>    2.
>    3.
>    4. use strict;

Also add "use warnings;".

>    5. use Mail::Sendmail;
>    6. use MIME::Base64;
>    7.
>    8. my $content = `cat tmp.txt`;
>    9.

Don't slurp files this way:

http://perl-begin.org/tutorials/bad-elements/#slurp


>    10. print "Sending an email .....";
>    11.

Don't you want a \n here?

>    12. my %mail = (
>    13.                       To            => "x...@xx.com",
>    14.                       From         =>  "x...@xx.com",
>    15.                        Subject       => "test",
>    16.                        content-type   => "text/plain",
>    17.                        content-transfer-encoding     => 'base64',
>    18.                         Message     => $content,
>    19.                           smtp       => "xx.xx.xx",

These are not aligned properly.

>    20. );
>    21.
>    22.
>    23. if  (sendmail %mail) { print "Mail send ok!\n";}
>    24.

Please Indent properly.

>    25. else {print "Error : $mail::Sendmail::errror\n"}
> 

It should be:  "$Mail::Sendmail::error" - you have a lowercase "m" and three 
consecutive "r"'s instead of two.

http://search.cpan.org/~mivkovic/Mail-
Sendmail-0.79/Sendmail.pm#$Mail::Sendmail::error

> 
> The "tmp.txt" is the content of Chinese .

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Funny Anti-Terrorism Story - http://shlom.in/enemy

Chuck Norris can make the statement "This statement is false" a true one.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to