in reply to cgi email Japanese contents scripting problem

I think you're going to have to delve into the world of MIME in order to get this correctly encoded. If you send mail without any indications, it automatically gets considered as text/plain, which would prevent correct interpretation of the Japanese characters.

Try MIME::Lite or MIME-tools. (The docs talk mostly about European "funny characters", but I imagine you should be able to make it work for other encoding schemes.)

  • Comment on Re: cgi email Japanese contents scripting problem

Replies are listed 'Best First'.
Re: Re: cgi email Japanese contents scripting problem
by stonemen (Initiate) on Jan 01, 2002 at 19:29 UTC
    Hi,

    Thanks for taking the time to think about and respond to my inquiry.

    I believe you are correct about the header which perhaps should have something like:

    content-transfer-encoding ISO-2022-JP

    and also perhaps

    content-type xxsomething

    There are several problems here:

    1. I don't know perl programming, so I don't know what or where to put { }; etc.

    2. And, then where do these lines go in the script?

    I apologize for trying to get an easy solution to this problem.

    Regards,

    Jim
      No problem. First the obligatory point. If you value the security of your web site, it is much better to use CPAN modules like CGI.pm to handle your CGI needs, something like Mail::Sendmail to handle the mailing, and something like MIME::Lite to create a nice MIME packet.

      Right now though, you're trying to get something to work and probably won't be willing to wade through all that. So as an interim workaround, I would suggest inserting into the part of the program that prints out the Header (The first group of print MAIL "....."; (up to print MAIL "\n\n", which ends the header) the following (not tested, as I don't know Japanese...)

      print MAIL "Content-Transfer-Encoding: ISO-2022-JP\n"; print MAIL "Content-Type: text/plain\n";
      But be careful with this! You are taking input that the user has input onto a webform and then blithely sending it out to an external program (usually sendmail). Someone who knows you were doing that could try sending a code to end the sendmail input followed by a command to do something nasty to your server.

      If you use Super Search you should be able to get a lot of information about CGI security and see how to patch this up better. Or, for an easier way, davorg, one of our resident monks, and the London Perl Mongers are working on easy programs to allow you to set this kind of thing up without giving away all the security. Look for it here: nms.