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
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
解决方案 »
- 菜鸟请教hibernate中多对多问题
- spring 注解事务控制 简单问题
- 关于客户端点击刷新按钮后跳转到登录界面的问题
- 想学习java方面的技术,又无从下手找不到头绪的进来.
- 用hibernate+struts跳转时出现的问题!
- 能否由外部向ibatis注入transaction manager?
- Date类型比较
- Weblogic里面的Workshop控件开发有谁做过,难吗?
- 我的JDK的路径有问题,请大家帮我看一下
- 高分求struts书 每本50分 决不失言,谢谢
- 关于struts中tiles的问题,郁闷了好久了。。。。
- 大家说说我要是办个假的身份证把岁数调大点然后去面试,分被公司发现吗????
不过,还是很感谢你,谢谢