//身份验证
      out.println(" AUTH LOGIN ");
      out.flush();
      response = in.readLine();
      ok = response.startsWith("334");
      if (!ok) 
        throw new IOException(response);
     
     //输入用户名和密码
      out.println( get64Code(user) );       //输入用户名
      out.flush();
      response = in.readLine();
      ok = response.startsWith("334");
      if (!ok) 
        throw new IOException(response); 
      out.println( get64Code(password) );   //输入密码
      out.flush();
   
以上即为发送邮件时输入用户名和密码验证代码。
如果用jmail则更简单