对了。另外我的包只有activation-1.1.jar,mail.jar(mail.jar是官网下载的javamail-1_4.zip解压目录下的,不是lib目录里的)。我介绍的够全的吧。会的告诉下到底是怎么回事呀。。

解决方案 »

  1.   

    我加了ssn.setDebug(true);后。打印出下边调试信息
    DEBUG SMTP: useEhlo true, useAuth true
    DEBUG SMTP: trying to connect to host "smtp.163.com", port 25, isSSL false
    220 163.com Anti-spam GT for Coremail System (163com[20050206])
    DEBUG SMTP: connected to host "smtp.163.com", port: 25
       .
       .
       .
    550 用户被锁定没人会吗????
      

  2.   

    貌似你的验证类写错了。这是我写的:
    public class SMTPAuth extends javax.mail.Authenticator{
        private String user = null;
        private String password =  null;
        /** Creates a new instance of SMTPAuth */
        public SMTPAuth(String u, String p) {
            this.user = u;
            this.password = p;
        }
        protected javax.mail.PasswordAuthentication getPasswordAuthentication(){
            return new javax.mail.PasswordAuthentication(this.user, this.password);
        }
    }其他的好像没什么问题:
                    Properties props = new Properties();
                    //Properties props = System.getProperties();
                    props.put("mail.smtp.host", ConnectDialog.smtpserver);
                    props.put("mail.transport.protocol","smtp");
                    props.put("mail.smtp.auth","true");
                    props.put("mail.smtp.port","25");
                    SMTPAuth auth = new SMTPAuth(ConnectDialog.user,ConnectDialog.pwd);
                    //设定发送邮件时需要进行身份验证
                    session = Session.getInstance(props,auth);
                    // session = Session.getDefaultInstance(props, auth);
                    session.setDebug(true);
                Message newMessage = new MimeMessage(session);
                newMessage.setFrom(new InternetAddress(getFrom()));
                //newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(getTo()));
                newMessage.setRecipients(Message.RecipientType.TO,address);//群发
                newMessage.setSubject(getSubject());
                newMessage.setSentDate(new java.util.Date());
                newMessage.setText(getContent());//            Transport transport = session.getTransport("smtp");
                transport.connect       (ConnectDialog.smtpserver,ConnectDialog.user,ConnectDialog.pwd);
                transport.sendMessage(newMessage,newMessage.getAllRecipients());
                transport.close();
        我把我做的贴出来,希望对你有帮助。        
      

  3.   

    >>550 用户被锁定换个sohu的邮箱。新注册的163邮箱不支持smtp pop3。