代码如下:
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.io.*;
import java.util.*;public class MailSender{
private static MimeMessage message;
public static void main(String [] args){
     String smtpHost="smtp.sohu.com";
     String from ="[email protected]";
     String to ="[email protected]";
     Properties props=new Properties();
     props.put("mail.smtp.host",smtpHost);
     props.put("mail.smtp.auth","true");
//需要验证
     Session session=Session.getDefaultInstance(props,
     new Authenticator() {
       public PasswordAuthentication
          getPasswordAuthentication() {
            return new PasswordAuthentication("yourName", "yourPassword");
       }
   });
session.setDebug(true);     try{
     InternetAddress[] address={new InternetAddress(to)};
     message=new MimeMessage(session);
     message.setFrom(new InternetAddress(from));
     message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to,false));
     message.setSubject("test");
     message.setSentDate(new Date());
     message.setText("this is java Mail22222!");
     Transport.send(message);
     System.out.println("send ok");
    }
    catch(Exception e){
     e.printStackTrace();
    }
    }
}发送到30%或50%后,就突然死亡
Debug信息如下:DEBUG: setDebug: JavaMail version 1.3.2
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.s
mtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.sohu.com", port 25, isSSL false
220 smtp.sohu.com ESMTP
DEBUG SMTP: connected to host "smtp.sohu.com", port: 25EHLO jsnstudi-8d12f1
250-smtp.sohu.com
250-PIPELINING
250-SIZE 10485760
250-ETRN
250-AUTH LOGIN
250 8BITMIME
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "SIZE", arg "10485760"
DEBUG SMTP: Found extension "ETRN", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
YmxkZHA=
334 UGFzc3dvcmQ6
b3Jpb25saW5l
235 Authentication successful
DEBUG SMTP: use8bit false
MAIL FROM:<[email protected]>
250 Ok
RCPT TO:<[email protected]>
250 Ok
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   [email protected]
DATA
354 Send from Rising mail proxy
Message-ID: <17905416.1148801688656.JavaMail.Jen@jsnstudi-8d12f1>
Date: Sun, 28 May 2006 15:34:48 +0800 (CST)
From: [email protected]
To: [email protected]
Subject: test
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bitthis is java Mail22222!
.
354
com.sun.mail.smtp.SMTPSendFailedException: 354        at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1
275)
        at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1149)
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:527)
        at javax.mail.Transport.send0(Transport.java:151)
        at javax.mail.Transport.send(Transport.java:80)
        at MailSender.main(MailSender.java:33)
QUIT
com.sun.mail.smtp.SMTPSendFailedException: 354        at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1
275)
        at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1149)
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:527)
        at javax.mail.Transport.send0(Transport.java:151)
        at javax.mail.Transport.send(Transport.java:80)
        at MailSender.main(MailSender.java:33)
小弟刚接触Java Mail 盼高人指点