下面代码发送本公司邮箱服务器内的邮件可以发送,但是发送到其它邮箱如126、qq邮箱都会报错
如下:DEBUG: setDebug: JavaMail version 1.3.1
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "sinokru.com", port 25220 crystal.websitehk.com ESMTP Exim 4.69 Tue, 28 Jun 2011 10:44:13 +0800
DEBUG SMTP: connected to host "sinokru.com", port: 25EHLO keno
250-crystal.websitehk.com Hello keno [218.13.224.250]
250-SIZE 36700160
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
DEBUG SMTP: Found extension "SIZE", arg "36700160"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "HELP", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<[email protected]>
250 OK
RCPT TO:<[email protected]>
550 authentication required
DEBUG SMTP: Invalid Addresses
DEBUG SMTP:   [email protected]
DEBUG SMTP: Sending failed because of invalid destination addresses
RSET
250 Reset OK
MailUtil error!
javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
class javax.mail.SendFailedException: 550 authentication requiredyssendMail
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:926)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:389)
at com.esoon.km.common.MailUtil.main(MailUtil.java:181)qq、126邮箱的pop3/smtp都以开启,也继承了验证类,不知问题出在哪里请指点,在线等待。。
如果有能成功的案例发给我下,谢谢
357102586****************************************************************************
 
                  try {
String generalCodeType = "utf-8";
// Step 1: Configure the mail session
// System.out.println("Configuring mail session for: " + smtpHost);
java.util.Properties props = new java.util.Properties();
props.put("mail.transport.protocol","smtp");//确定发送协议
props.put("mail.smtp.auth", true);
props.put("mail.smtp.host", "sinokru.com");


MyAuthor author1=new MyAuthor("[email protected]","*******");
Session mailSession = Session.getDefaultInstance(props,author1);
mailSession.setDebug(true);
// Step 2: Construct the message
//System.out.println("Constructing message - from=" + from + " to="+ to);
InternetAddress fromAddress = new InternetAddress("[email protected]");
InternetAddress toAddress = new InternetAddress("[email protected]");
MimeMessage testMessage = new MimeMessage(mailSession);
testMessage.setFrom(fromAddress);
testMessage.addRecipient(javax.mail.Message.RecipientType.TO,toAddress);// TO
// System.out.println(df.format(sendDate));
testMessage.setSentDate(new Date());
testMessage.setSubject(MimeUtility.encodeText("000000",generalCodeType, "B"));
testMessage.setContent("hello word", "text/html;charset="+ generalCodeType); // System.out.println("Message constructed");
// Step 3: Now send the message
Transport transport = mailSession.getTransport("smtp");
 transport.connect("sinokru.com", "[email protected]", "123456");

transport.sendMessage(testMessage, testMessage.getAllRecipients());
transport.close();
//System.out.println("Message sent!"); } catch (Exception e) {
System.out.println("MailUtil error!");
e.printStackTrace();
}

System.out.println("yssendMail");
}