【问题标题】:Unable to reply messages in yahoo using JAVA MAIL API无法使用 JAVA MAIL API 在 yahoo 中回复消息
【发布时间】:2020-02-22 03:53:28
【问题描述】:

同一段代码在 Gmail 中成功地用于回复消息,但在 yahoo 中,我遇到了错误。

这是我尝试过的代码

Message[] messages2 = folder.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
Message msg =  messages2[i];
 System.out.println("\n 1st ===> setup Mail Server Properties..");
                                        mailServerProperties = System.getProperties();
                                        mailServerProperties.put("mail.smtp.port", "587");
                                        mailServerProperties.put("mail.smtp.auth", "true");
                                        mailServerProperties.put("mail.smtp.starttls.enable", "true");
System.out.println("Mail Server Properties have been setup successfully..");
                                        getMailSession = Session.getDefaultInstance(mailServerProperties, null);

                                        Message replyMessage = new MimeMessage(getMailSession);
                                          replyMessage = (MimeMessage) msg.reply(false);
                                          replyMessage.setFrom(new InternetAddress(to));
                                          replyMessage.setText("Thanks");
                                          replyMessage.setReplyTo(msg.getReplyTo());

                                          // Send the message by authenticating the SMTP server
                                          // Create a Transport instance and call the sendMessage
                                          Transport t = session.getTransport("smtp");
                                          try {
                                     //connect to the smpt server using transport instance
                                     //change the user and password accordingly 
                                         t.connect("smtp.mail.yahoo.com",table_user, table_pass);
                                         t.sendMessage(replyMessage,
                                                replyMessage.getAllRecipients());
                                          } finally {
                                             t.close();
                                          }
                                          System.out.println("message replied successfully ....");

我得到的错误:

com.sun.mail.smtp.SMTPSendFailedException: 550 Request failed; Mailbox unavailable

at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1829)
at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1634)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:889)
at mail$8.doInBackground(mail.java:1114)
at mail$8.doInBackground(mail.java:1)
at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at javax.swing.SwingWorker.run(SwingWorker.java:334)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

请指点我正确的方向,我做错了什么。

【问题讨论】:

    标签: smtp jakarta-mail yahoo-mail


    【解决方案1】:

    Yahoo 邮件服务器不喜欢您的回复邮件的收件人之一。尝试启用JavaMail debug output,您可能会获得有关问题所在的更多信息。

    还请注意,您是通过使用 MimeMessage 构造函数创建replyMessage,然后将该值丢弃并将其分配给reply 方法的返回值。你可以摆脱对构造函数的调用,它什么都不做。

    【讨论】:

      猜你喜欢
      • 2012-12-08
      • 1970-01-01
      • 2011-12-09
      • 1970-01-01
      • 2016-09-25
      • 1970-01-01
      • 2018-10-17
      • 1970-01-01
      • 2016-01-12
      相关资源
      最近更新 更多