1.身份验证类:
package com.neusoft.qj;import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
public class SmtpAuthenticator extends Authenticator {
    String username;
    String password;SmtpAuthenticator() { }
//重载身份验证
public PasswordAuthentication performCheck(String user,String pass){
username = user;
password = pass;

return new PasswordAuthentication(username, password);
}
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password); 

}2.调用时加上:
  SmtpAuthenticator Auth = new SmtpAuthenticator();
  Auth.performCheck(this.strUserName, this.strUserPassword);
  session = Session.getInstance(props, Auth);//取得Session