方法:JAVAMAIL方面的
public void send (String host,String fromaddress,String recipient_address,String tocontent,String title) throws Exception{
int flag;
Transport transport;
Properties mailpros=new Properties();
mailpros.put("mail.smtp.host",host);
mailpros.put("mail.smtp.auth", "true");
mailpros.put("mail.smtp.user",fromaddress);
mailpros.put("mail.smtp.password","qq");
Session mailsession=Session.getInstance(mailpros);
MimeMessage message=new MimeMessage(mailsession);
InternetAddress sender=new InternetAddress(fromaddress);
message.setFrom(sender);
message.setSubject(title);
message.setText(tocontent);
message.setRecipient(Message.RecipientType.TO,new InternetAddress(recipient_address));
message.saveChanges();
Transport.send(message);
System.out.println("?件?送成功");
}
执行这方法后出现的异常是:javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.AuthenticationFailedException
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at com.Mail.send(Mail.java:56)
at test.test.main(test.java:12)
希望大家给我看看.谢谢.
public void send (String host,String fromaddress,String recipient_address,String tocontent,String title) throws Exception{
int flag;
Transport transport;
Properties mailpros=new Properties();
mailpros.put("mail.smtp.host",host);
mailpros.put("mail.smtp.auth", "true");
mailpros.put("mail.smtp.user",fromaddress);
mailpros.put("mail.smtp.password","qq");
Session mailsession=Session.getInstance(mailpros);
MimeMessage message=new MimeMessage(mailsession);
InternetAddress sender=new InternetAddress(fromaddress);
message.setFrom(sender);
message.setSubject(title);
message.setText(tocontent);
message.setRecipient(Message.RecipientType.TO,new InternetAddress(recipient_address));
message.saveChanges();
Transport.send(message);
System.out.println("?件?送成功");
}
执行这方法后出现的异常是:javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.AuthenticationFailedException
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at com.Mail.send(Mail.java:56)
at test.test.main(test.java:12)
希望大家给我看看.谢谢.
解决方案 »
- 分类 树状 UI
- struts 传值
- 用struts开发论坛的问题,做过的请进来讨论
- 用Jsp的兄弟们,我想比较Asp.Net与Jsp读取数据库并显示的方法,请给出Java代码,谢谢!
- 如何让weblogic自动加载新编译出来的.class文件???
- 散分,最近做的个东西,用adsl和宽带的可以利用www.ibzoo.com免费的动态域名服务实现在家拥有自己的网站?
- 求删除一个文件夹中文件名以a开头的所有文件代码,谢谢。
- jsp中包含文件的问题
- 急,求高手指导: 浏览器关闭时,session 立即失效问题
- 使用java的cas sso 实现单点登陆时遇到的web前后端分离如何实现cas单点登陆的问题
- 为什么这段代码在浏览器中不能显示?
- 谁有免费的网站生成器软件,能否给我发一个!!!!!!!!!
但是你没有发现你没有提供一个可以输入帐号密码的地方吗?class Auth extends Authenticator
{
String username="";
String password="";
public Auth(String username,String password){
this.username=username;
this.password=password;
}
public PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(username,password);
}
}
sendMailSession=Session.getDefaultInstance(props,(Authenticator)auth);