Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: Java and Japanese e-mail



--------------------------------------------------------
tlug note from Craig Oda <craig@example.com>
--------------------------------------------------------
Hi,
this is semi-related to Linux and Japanese, but is a little
off-topic for TLUG.  I'll post some more Linux-centric info goodies in 
a bit.  I'm using a Java servlet on Linux and Java object on Linux 
to send the contents
of a form to some people.  The contents of the form are in Japanese.
It could either be EUC or ShiftJIS.  I've never done this before,
and assume that there is a simple answer.  I want to do it
all in Java and avoid using native methods, so I can't use
stuff like nkf.

My object works fine with ASCII, but I think I need to convert
to JIS before talking to sendmail.  

In order to send the mail I am connecting directly to the
SMTP port on 25 and sending the greeting and data.  My assumption
is that I need to convert the Japanese into JIS before sending.
Is this correct?  I'm doing it with ShiftJIS (not my machine  :-)
and getting bakemoji.

I'm curious about a couple things, 1) is there an easier way
to do this? 2) has anyone sent Japanese with Java before?

Also, anyone interesting in starting a seperate Java discussion
thread?


My code fragment to follow.  It works with ASCII.

        try { 
          // open a network socket on the SMTP port
          Socket server = new Socket("mail.twics.com", 25);     

          // set up network print stream
          PrintWriter sendmailout =
            new PrintWriter(
                            new BufferedWriter(
                                             new OutputStreamWriter(server.getOutputStream())), true);

         // send mail greetings and message
          sendmailout.println("HELO my-machine.twics.com\n" 
                               + "MAIL FROM:<whoever@example.com>\n"
                               + "RCPT TO:<person@example.com>\n"
                               + "DATA\n");

          // send the body of the e-mail here
          sendmailout.println("Hi, this is an automated message"
                              + " with the results of the "
                              + "form." );
          
          Date date_written = new Date();
          sendmailout.println("This note was sent on " + date_written);

    // the mail program requires a single dot on a line
          // by itself
          sendmailout.println(".");
          sendmailout.println("QUIT");
          sendmailout.close();
            



--------------------------------------------------------
"Knowledge is the air and light of civilization.  Transform it and you
transform all else."
Craig Oda 	craig@example.com	
   TWICS - IEC Building, 1-21 Yotsuya, Shinjuku-ku, Tokyo 160 JAPAN
Main Reception: 03-3351-5977	Fax: +81-3-3353-6096

Next TLUG meeting is Saturday October 11, 1997
-----------------------------------------------------------------
a word from the sponsor will appear below
TWICS - Japan's First Public-Access Internet System.
www.twics.com  info@example.com  Tel:03-3351-5977  Fax:03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links