props.put("mail.pop3.auth","true"); //这行一定要有改成:props.put("mail.smtp.auth","true"); //这行一定要有
解决方案 »
- 万能的csdn,谁是编写JAVA高手十万火急救命
- 运行java桌面应用程序时有多个窗口,怎样在任务栏中只显示一个图标
- 能利用Math.random()生成随机负数么?
- 今夜,你yy着谁
- 怎么以追加的方式打开文件啊?或者怎样往文件的末尾加入一行?
- 请问 Hashtable<?,?> 是甚莫意思
- 请大家帮看一下这是怎么回事啊!!??
- 学习CORBA的环境
- 能否实现applet之间的通信,详情见内......
- ◎◎急问applet画图中用drawImage(,x,y,this)方法后如何在此image下添加一个label??
- 编译通过后得到的东西和原文件不一样?
- 在Java程序中怎样动态的检查SQL语句是否正确?
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 webmail.mymail.main(mymail.java:54)就是不行,气死我了!
还有一点,发信人的地址应该与验证人的地址是一致的。也就是你用zmrjl验证,就要用它作为发信人的地址[email protected]才行。
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication ("wen-jian", "");
}
}
public static void send(String smtpServer, String to, String from
, String subject, String body)
{
SimpleSender SimpleSender1 = new SimpleSender();
try
{
Properties props = System.getProperties(); // -- Attaching to default Session, or we could start a new one -- props.put("mail.smtp.host", smtpServer);
props.put("mail.smtp.auth","true"); MyAuthenticator auth = new MyAuthenticator(); Session session = Session.getDefaultInstance(props,auth); // -- Create a new message --
Message msg = new MimeMessage(session); // -- Set the FROM and TO fields --
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to, false)); // -- We could include CC recipients too --
// if (cc != null)
// msg.setRecipients(Message.RecipientType.CC
// ,InternetAddress.parse(cc, false)); // -- Set the subject and body text --
msg.setSubject(subject);
msg.setText(body); // -- Set some other header information --
msg.setHeader("X-Mailer", "LOTONtechEmail");
msg.setSentDate(new Date()); // -- Send the message --
Transport transport = session.getTransport("smtp");
Transport.send(msg); System.out.println("Message sent OK."); Store store = session.getStore("pop3");
store.connect("smtp.163.net", "wen-jian","123456");
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
Message message[] = folder.getMessages();
System.out.println(((MimeMessage)message[0]).getContent());
}
这个是我试过的
smtpServer是什么??
mymail mm=new mymail("zmrljl","zmrljl");
你发信的地址是zmrljl吗?
你发信的地址的密码也是zmrljl吗?
要人证的话,就需要实际的邮箱用户和密码!