你这个是身份认证没有通过,把:
Session session =Session.getDefaultInstance(props,null);
修改为:
Session session = Session.getDefaultInstance(properties, myauth);
MyAuthenticator myauth = new MyAuthenticator("你的用户名", "你的密码");
另外添加一个类:
public class MyAuthenticator extends javax.mail.Authenticator {
private String strUser; private String strPwd; public MyAuthenticator(String user, String password) {
this.strUser = user;
this.strPwd = password;
} protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(strUser, strPwd);
}
}
就可以了。
Session session =Session.getDefaultInstance(props,null);
修改为:
Session session = Session.getDefaultInstance(properties, myauth);
MyAuthenticator myauth = new MyAuthenticator("你的用户名", "你的密码");
另外添加一个类:
public class MyAuthenticator extends javax.mail.Authenticator {
private String strUser; private String strPwd; public MyAuthenticator(String user, String password) {
this.strUser = user;
this.strPwd = password;
} protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(strUser, strPwd);
}
}
就可以了。
解决方案 »
- struts关于文件上传,总是出错,哪位大哥帮忙看看??
- 求一套比较完善的防注入代码,包括sql、html....
- [Struts1.x]在ActionForm中使用JavaBean的话,怎么用Validator框架验证?
- resin3.1.3配置连接池,通过hibernate访问数据库失败,而resin3.0.19成功,怎么解决?
- hibernate中文查询问题
- 如何每隔一段时间产生一个操作
- JAVA写的程序能够放在浏览器里面执行吗?
- 这个问题有点味!!
- 用什么工具来编辑转换为struts格式的jsp文件?
- 请教高手,用BLOB生成图片碰到的问题!
- [200分]通过以下DAO操作proxool连接池访问量大的时候,老是有问题?DAO如下:
- 一个JavaMail在websphere的奇怪问题
刚才我查出问题了,主要是Prperties中的属性没设置好,谢谢各位大侠对我的帮助,谢谢各位