用JAVAMAIL写了个客户端的EMAIL发送程序,用自己建的邮件服务器可以发送,但选用外部服务器如smtp.163.com就出现验证的问题,怎么加个验证,哪位朋友告知下

解决方案 »

  1.   

    import javax.mail.*;import javax.swing.*;import java.util.*; public class PopupAuthenticator extends Authenticator {             public PasswordAuthentication getPasswordAuthentication() {                        String username="cx", password="devilsun";                        /*String result = JOptionPane                                                .showInputDialog("Enter 'username,password'");                        StringTokenizer st = new StringTokenizer(result, ",");                        username = st.nextToken();                        password = st.nextToken();*/                        System.out.println(username+" "+password);                        return new PasswordAuthentication(username, password);            }}上面是授权要实现的方法
    调用方法是:PopupAuthenticator auth=new PopupAuthenticator(); sendMailSession = Session.getInstance(props, auth);加我qq,我还有事:196696635