sun.misc.BASE64Decoder一个例子:
import sun.misc.*;
import java.awt.*;
import java.io.*;
public class Base64Decode {  public static void main(String[] args) {    if (args.length >= 2) {
      try {
        InputStream is = new FileInputStream(args[0]);
        OutputStream os = new FileOutputStream(args[1]);
        BASE64Decoder b64dc = new BASE64Decoder();
        b64dc.decodeBuffer(is, os);
      }
      catch (IOException e) {
        System.err.println(e);
      }
    } // end if  }  // end main
输入的是一个encode的文件,输出就是解码后的文件了。

解决方案 »

  1.   

    TO: david017(非程序员)  THX~~~~ i get it另外那两个问题有想法吗?
      

  2.   

    第2个问题有个协议的,可能就叫esmtp,
    去找找rfc的文档,我不知道具体是RFC????了。
      

  3.   

    第3个问题,应该textfiled能解决,
    我做过在JEditorPane里接收<Ctrl>+<Enter>键的,,,
    如下:
        KeyStroke stroke1 = KeyStroke.getKeyStroke     (KeyEvent.VK_ENTER,ActionEvent.CTRL_MASK,true);//创建一个KeyStroke类    最后一个参数的意思是是否在Keyrelease时触发此事件
        JEditorPane jEditorPane1 = new JEditorPane();   jEditorPane1.registerKeyboardAction(new ActionListener(){
                //要执行的方法
                public void actionPerformed(ActionEvent e){
                    System.out.println("OK");
                }
            },stroke1,JComponent.WHEN_IN_FOCUSED_WINDOW);
        }
        registerKeyboardAction方法的参数意思是这样的
        1.ActionListener对象,可以定义你要执行的方法
        2.KeyStroke 对象,定义触发事件的条件
        3.何时按Ctrl+Enter时发生此事件,比如
            JComponent.WHEN_IN_FOCUSED_WINDOW
            JComponent.WHEN_FOCUSED等
      

  4.   

    验证的问题我已经解决了,可是不能发信加上验证后,哈哈!代码如下:
           send( in, out, "AUTH LOGIN" );
           send( in, out, get64Code("user_ID") );
           send( in, out, get64Code("password") ); 
    转换方法:
      public String get64Code( String code32 ){
           //把字符串转换成BASE64格式
           String code64 = new sun.misc.BASE64Encoder().encode(code32.getBytes()); 
           return code64;
      } 共同提高。
      

  5.   

    faint...User_ID, password解码作什么阿。
    只有邮件内容用base64编码后才需要解码得到汉字的。(或其他,日文/泰文等)
    也可能是用QuotaPrintable编码的,那就用QuotaPrintable解码。
    userid,password在pop3/smtp协议里都是明文传送.
      

  6.   

    为什么 是这个错误?
    S:220 tebie coremail2.0 system SMTP(Anti Spam+) Server ready 
    C:helo abc 
    S:250 192.168.30.29 
    C:auth login 
    S:334 VXNlcm5hbWU6 
    C:lucky_i 
    S:334 UGFzc3dvcmQ6 
    C:8820831 
    S:535 Error: authentication failed用户名 和密码 不会错的
      

  7.   

    为什么 是这个错误?
    S:220 tebie coremail2.0 system SMTP(Anti Spam+) Server ready 
    C:helo abc 
    S:250 192.168.30.29 
    C:auth login 
    S:334 VXNlcm5hbWU6 
    C:lucky_i 
    S:334 UGFzc3dvcmQ6 
    C:8820831 
    S:535 Error: authentication failed用户名 和密码 不会错的
      

  8.   

    用户名,密码要经过BASE64编码才行
      

  9.   

    import java.util.*;
    import java.io.*;
    import java.net.*;
    import java.sql.*;public class SendMail
    {
        public static boolean AUTH = false;
        public String phone = "";
        public String host = "smtp.21cn.com";
        public String to = "";
        public String from = "[email protected]";
        public String subject = "";
        public String msg = "";
        //public String baseCode = "8bit";
        public String charset = "GB2312";
        public String conType = "text/plain";    public SendMail( String _smtp, String _to, String _subject, String _msg )
        {
            host = _smtp;
            to = _to;
            subject = _subject;
            msg = _msg;    }    
        private String sendCommand( PrintWriter mailOut, BufferedReader mailIn, String cmd )
        {
            mailOut.print( cmd + "\r\n" );
            mailOut.flush();
            String line = new String();
            try
            {
                line = mailIn.readLine();
            }
            catch( IOException e )
            {
                return null;
            }
            return line;
        }
        
        private boolean recIsCorr( String line, int iValue )
        {
            if( (line != null) && (line.length() >= 3) )
            {
                String sTemp = line.substring( 0, 3 );
                try
                {
                    int iTemp = (new Integer( sTemp )).intValue();
                    if( iTemp == iValue )
                        return true;
                    else
                    {
                        return false;
                    }
                }
                catch( Exception e )
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
        
        private String sendData( PrintWriter mailOut, BufferedReader mailIn, String from, String to, String subject, String msg, String conType, String charset )
        {
            msg = "Date: " + (new java.util.Date()).toString() + "\r\n"
                + "Content-Type: " + conType + "; charset=" + charset + "\r\n"
                + "MIME-Version: 1.0 \r\n\r\n" + msg;
            msg = "From: " + from + "\r\n" + msg;
            msg = "To: " + to + "\r\n" + msg;
            msg = "Subject: " + subject + "\r\n" + msg;
            mailOut.print( msg );
            mailOut.print( "\r\n.\r\n" );
            mailOut.flush();
            String line = new String();
            
            try
            {
                line = mailIn.readLine();
            }
            catch( IOException e )
            {
                return null;
            }
            return line;
        }            public String send_EMail()
        {
            AUTH = isNeedAUTH( host );
            try
            {
                Socket sock;
                PrintWriter mailOut;
                BufferedReader mailIn;
                sock = new Socket( host, 25 );
                mailOut = new PrintWriter( sock.getOutputStream(), true);
                mailIn = new BufferedReader( new InputStreamReader( sock.getInputStream() ) );
                boolean result = false;
                String line = mailIn.readLine();
                result = recIsCorr( line, 220 );
                if( !result )
                    return "发送失败!";                            
                
                if( host.equals( "smtp.sina.com.cn" ) )
                    line = sendCommand( mailOut, mailIn, "EHLO " + host );
                else
                    line = sendCommand( mailOut, mailIn, "HELO " + host );
                result = recIsCorr( line, 250 );
                if( !result )
                    if( !recIsCorr( line, 220 ) ) return "发送失败!";        
                
                if( AUTH )
                {
                    line = sendCommand( mailOut, mailIn, "AUTH LOGIN" );
                    line = sendCommand( mailOut, mailIn, get64Code("yourname") );
                    line = sendCommand( mailOut, mailIn, get64Code("yourpassword") );
                }
                                    
                line = sendCommand( mailOut, mailIn, "MAIL FROM:" + from );
                result = recIsCorr( line, 250 );
                if( !result )
                    if( !recIsCorr( line, 235 ) ) return "发送失败!";        
                
                line = sendCommand( mailOut, mailIn, "RCPT TO:" + to );
                result = recIsCorr( line, 250 );
                if( !result )
                    if ( !recIsCorr( line, 334 ) )
                        return "发送失败!";
                
                line = sendCommand( mailOut, mailIn, "DATA " );
                result = recIsCorr( line, 354 );
                if( !result ) 
                    if( !recIsCorr( line, 334 ) ) 
                        if( !recIsCorr( line, 250 ) ) return "发送失败!";
                
                line = sendData( mailOut, mailIn, from, to, subject, msg, conType, charset );
                
                result = recIsCorr( line, 250 );
                if( !result ) 
                    if( !recIsCorr( line, 235 ) ) 
                        if( !recIsCorr( line, 354 ) ) return "发送失败!";
                
                line = sendCommand( mailOut, mailIn, "QUIT" );
                result = recIsCorr( line, 221 );
                if( !result ) 
                    if( !recIsCorr( line, 250 ) ) return "发送失败!";
                
                sock.close();            
            }
            catch( IOException e )
            {
                return "发送失败!";
            }
            return "发送成功!";
        }        private String get64Code( String code32 )
        {
            String code64 = new sun.misc.BASE64Encoder().encode(code32.getBytes()); 
            return code64;
        }    private boolean isNeedAUTH( String host )
        {
            if( host.equals( "smtp.263.net" ) )
                return true;
            if( host.equals( "smtp.163.net" ) )
                return true;
            if( host.equals( "smtp.sina.com.cn" ) )
                return true;
            if( host.equals( "smtp.sohu.com" ) )
                return true;
                
            return false;
        }
    }这是我的发送原程序,你看看
      

  10.   

    TO:gxj0637()厉害,太有帮助了 谢谢你
      

  11.   

    请问哪有ESMTP的资料呀  我是一点都不知道还有java.awt.*里的组件List到底能不能接受用户输入呢?就是说像TextField