To: zealVampire(蚊子+鹤舞白沙) 
如何做这个验证身份,不啻请教!

解决方案 »

  1.   

    //身份认证类
    public class Email_Autherticator extends Authenticator 

    String username, password;
    public Email_Autherticator(String username,String password) 

    super(); 
     this.username=username;
     this.password=password;

    public PasswordAuthentication getPasswordAuthentication() 

    return new PasswordAuthentication(username,password); 

    } //发送邮件代码片断
    Properties props = new Properties(); 
    Authenticator auth = new Email_Autherticator(username,password); 
    props.put("mail.smtp.host",host); 
    props.put("mail.smtp.auth","true"); 
    Session session = Session.getDefaultInstance(props,auth);
    ...... 
    得到session后,剩下的就都一样了