这个错误的根本原因是没有没有匹配的或者有多个mail.jar 和 activation.jar 你检查以下你装载的包是否重复了 bugzero 包有,而且servlet 驱动有它自己的这两个包
解决方案 »
- jsp中的内置对象out.print方法和response.getWrite().print()有什么区别
- 在weblogic中怎么配置数据源(数据库连接池)
- 各位帮忙啊,我怎么设计表结构才能在MYECLIPSE中自动 生成一对一的HBM呀
- 下载时出现重复调用下载方法的问题,求大神解决
- JSP与ACCESS连接的问题
- !!!继续关注用Java抽取doc文件的内容!!!(jacob技术)
- 关于hibernate删除的问题?????
- 请问在Web Services Menthod里面怎么读war包里的文件?
- 关于J2EE中创建Entity Bean的问题
- 就要去找工作了!心里没底!
- Websphere的问题
- 单态类中的 公用方法与静态方法使用的讨论?
The Java Activation Framework used by JavaMail is not configured correctly.
It doesn't know how to handle the text/html content type. An html handler is provided in JavaMail 1.1.3 but the mailcap file is not configured to use it.Add to your mailcap file the line: text/html;; x-java-content-handler=com.sun.mail.handlers.text_html and create a multipart message when sending html messages, otherwise it will not be recognised as an HTML page from the client. HTML messages does not cause this problem with the 1.2 release of the JavaMail API. 重新下载试试
1. JavaMail 1.3.1
http://java.sun.com/products/javamail/downloads/index.html2. JAF 1.0.2
http://java.sun.com/products/javabeans/glasgow/jaf.html
我的代码,经过无数次的验证package com.kenfor.tradenet.MailSystem1;import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.util.*;
/**
*
* <p>Title:</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author
* @version 1.0
*/
class Email_Autherticatorbean
extends Authenticator {
private String m_username = null;
private String m_userpass = null;
/**
* 设置认证用户名
* @param username
*/
public void setUsername(String username) {
m_username = username;
} public void setUserpass(String userpass) {
m_userpass = userpass;
} public Email_Autherticatorbean(String username, String userpass) {
super();
setUsername(username);
setUserpass(userpass); } public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(m_username, m_userpass);
}
}public class SendMail { public SendMail() {
} public static void send(String smtpServer, String to, String from,
String subject, String body,String username,String password) {
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.transport.user","showerxp");
//props.put("mail.transport.password","111111");
props.put("mail.smtp.auth", "true");
javax.mail.Session session = Session.getInstance(props, new Email_Autherticatorbean(username,password));
//Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
//javax.mail.Session session = Session.getInstance(props,null);
// javax.mail.Message msg = new MimeMessage(session);
javax.mail.internet.MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
msg.setSubject(subject);
msg.setText(body,"gb2312");
msg.setHeader("X-Mailer", "KenforMail");
//msg.setDataHandler(new DataHandler(body, "text/html"));
msg.setSentDate(new Date());
javax.mail.Transport.send(msg);
System.out.println("Message sent OK.");
}
catch (Exception e) {
e.printStackTrace();
}
} public static void main(String args[])
{
send("smtp.163.com", "收信人", "发信人",
"标题", "内容","用户名","密码");
}}