我昨天用javamail来实现邮件的发送。一开始用我自己的免费163.可以正常发送。。可是当我用同学的企业邮箱。服务器也设置好了。可怎么也发送不成功。把相应的信息配置在foxmail上也可以收发成功。后来我用QQ来发。也发送不成功。均报javax.mail.AuthenticationFailedException异常。我在里面写了一个校验器呢。怎么还会报这个错职。。
public MyAuthenticator(String username, String password) {
this.userName = username;
this.password = password;
}
protected PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication(userName, password);
}
客户端代码:
public static void main(String[] args) throws ParseException{
//这个类主要是设置邮件
MailSenderInfo mailInfo = new MailSenderInfo();
mailInfo.setMailServerHost("smtp.qq.com");
mailInfo.setMailServerPort("25");
mailInfo.setValidate(true);
mailInfo.setUserName("xxx");
mailInfo.setPassword("xxx");//您的邮箱密码
mailInfo.setFromAddress("xxx@qq.com");
mailInfo.setToAddress("xxxx@163.com");
mailInfo.setSubject("abc");
mailInfo.setContent("abcccc==");
//这个类主要来发送邮件
SimpleMailSender sms = new SimpleMailSender();
sms.sendTextMail(mailInfo);//发送文体格式
// sms.sendHtmlMail(mailInfo);//发送html格式
}
哪位仁兄知道解决方案请帮个忙。万分感激。也可以QQ联系我:969994489 邮箱j2ee_.net@163.com