这个错误的根本原因是没有没有匹配的或者有多个mail.jar 和 activation.jar 你检查以下你装载的包是否重复了 bugzero 包有,而且servlet 驱动有它自己的这两个包

解决方案 »

  1.   

    以下內容转贴自 http://www.jguru.com/faq/view.jsp?EID=237257
    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 
      

  2.   

    mbp.setDataHandler(new DataHandler(source));这一句不要。还有,搜索以前的帖子。
    我的代码,经过无数次的验证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", "收信人", "发信人",
             "标题", "内容","用户名","密码");
      }}