返回列表 发帖

[其他技术] 有关javamail的问题

  1. package com.javamail.test;
  2. import javax.mail.internet.MimeMessage;
  3. import javax.mail.*;
  4. import javax.mail.internet.*;
  5. import java.util.*;
  6. public class TestJavamain {
  7. public static void main(String[] args) throws Exception {
  8.   Properties props=new Properties();
  9.   props.setProperty("mail.smtp.auth", "true");
  10.   props.setProperty("mail.transport.protocol", "smtp");
  11.   Session session=Session.getInstance(props);
  12.   session.setDebug(true);
  13.   Message msg=new MimeMessage(session);
  14.   msg.setText("我爱我家!");
  15.   msg.setFrom(new InternetAddress("lili@sohu.com"));
  16.   Transport transport=session.getTransport();
  17.   transport.connect("smtp.sina.com", 25, "xinlangli041 ", "041041");
  18.   transport.sendMessage(msg, new Address[]{new InternetAddress("lijia041@126.com")});
  19.   transport.close();
  20. }
  21. }
  22. 为何我的电脑 在连 新浪的smtp服务器时总是报下面的异常长呀?我在cmd 命令行窗口 使用 smtp.sina.com 25  命令 进入  按照提示输入编码后的用户名和密码  连接时同样也出现验证失败的提示,这是出什么问题了,是不是我的网络设置的有问题??

  23. 异常信息
  24. DEBUG: setDebug: JavaMail version 1.4.3
  25. DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
  26. DEBUG SMTP: useEhlo true, useAuth true
  27. DEBUG SMTP: trying to connect to host "smtp.sina.com", port 25, isSSL false
  28. 220 irxd5-203.sinamail.sina.com.cn ESMTP
  29. DEBUG SMTP: connected to host "smtp.sina.com", port: 25
  30. EHLO C300620A400947E
  31. 250-irxd5-203.sinamail.sina.com.cn
  32. 250-8BITMIME
  33. 250-SIZE 52428800
  34. 250-AUTH PLAIN LOGIN
  35. 250 AUTH=PLAIN LOGIN
  36. DEBUG SMTP: Found extension "8BITMIME", arg ""
  37. DEBUG SMTP: Found extension "SIZE", arg "52428800"
  38. DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
  39. DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN"
  40. DEBUG SMTP: Attempt to authenticate
  41. DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM
  42. AUTH LOGIN
  43. 334 VXNlcm5hbWU6
  44. eGlubGFuZ2xpMDQxIA==
  45. 334 UGFzc3dvcmQ6
  46. MDQxMDQx
  47. 535 #5.7.0 Authentication failed
  48. Exception in thread "main" javax.mail.AuthenticationFailedException: 535 #5.7.0 Authentication failed
  49. at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:648)
  50. at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:583)
  51. at javax.mail.Service.connect(Service.java:291)
  52. at com.javamail.test.TestJavamain.main(TestJavamain.java:18)
复制代码

提问赏金:5金币
获奖名单 : 还未派发赏金

"I had not known you a month before I felt that you were the last man in the world whom I could ever be prevailed on to marry"

TOP

这个应该不是你的错,这是新浪邮件服务器设置了限制的,它会限制通过smtp连续的发送邮件。

TOP

回复 2# 無銘指 的帖子

  1. 我设置了邮箱设置里开启了相对的服务,问题是能连接上了,按照下面的提示邮件发出去了,可是收件箱收不到邮件呀!!这是什么问题吗?
  2. 250-AUTH PLAIN LOGIN
  3. 250 AUTH=PLAIN LOGIN
  4. DEBUG SMTP: Found extension "8BITMIME", arg ""
  5. DEBUG SMTP: Found extension "SIZE", arg "52428800"
  6. DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
  7. DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN"
  8. DEBUG SMTP: Attempt to authenticate
  9. DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM
  10. AUTH LOGIN
  11. 334 VXNlcm5hbWU6
  12. eGlubGFuZ2xpMDQx
  13. 334 UGFzc3dvcmQ6
  14. MDQxMDQx
  15. 235 #2.0.0 OK Authenticated
  16. DEBUG SMTP: use8bit false
  17. MAIL FROM:<itca_dd@sina.com>
  18. 250 sender <itca_dd@sina.com> ok
  19. RCPT TO:<xinlangli041@sina.com>
  20. 250 recipient <xinlangli041@sina.com> ok
  21. RCPT TO:<suhuli041@sohu.com>
  22. 250 recipient <suhuli041@sohu.com> ok
  23. DEBUG SMTP: Verified Addresses
  24. DEBUG SMTP:   xinlangli041@sina.com
  25. DEBUG SMTP:   suhuli041@sohu.com
  26. DATA
  27. 354 Send from Rising mail proxy
  28. From: itca_dd@sina.com
  29. To: xinlangli041@sina.com, suhuli041@sohu.com
  30. Message-ID: <16259139.0.1262061263125.JavaMail.Administrator@smtp.sina.com>
  31. Subject: =?GBK?B?1tDOxNb3zOI=?=
  32. MIME-Version: 1.0
  33. Content-Type: text/plain; charset=us-ascii
  34. Content-Transfer-Encoding: 7bit

  35. aaaaaaaa
  36. .
  37. 250
  38. QUIT
  39. 221 irxd5-201.sinamail.sina.com.cn
复制代码

TOP

原帖由 無銘指 于 2009-12-28 23:06 发表
邮箱设置里开启了相对的服务没?

能留下你的QQ吗?

TOP

TOP

原帖由 lijia245235993 于 2009-12-29 12:42 发表

能留下你的QQ吗?

Q我不常用,你在这里提问不是更多人能帮到你吗
"I had not known you a month before I felt that you were the last man in the world whom I could ever be prevailed on to marry"

TOP

倚楼听风雨,笑看江湖路。。。

TOP

TOP

回复 9# carson 的帖子

换了个服务器,试试了,总是验证失败,连接不到服务器上!

TOP

返回列表