gpt4 book ai didi

java - 如何通过 JavaMail 从 Yahoo 服务器发送电子邮件?

转载 作者:行者123 更新时间:2023-11-30 09:31:08 24 4
gpt4 key购买 nike

我一直试图找到一个更新到最新版本的 JavaMail 的网站,但每当我尝试时,我都会遇到这个烦人的错误(已启用调试)
求助?

DEBUG: setDebug: JavaMail version 1.4.5
DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]
DEBUG POP3: mail.pop3.rsetbeforequit: false
DEBUG POP3: mail.pop3.disabletop: false
DEBUG POP3: mail.pop3.forgettopheaders: false
DEBUG POP3: mail.pop3.cachewriteto: false
DEBUG POP3: mail.pop3.filecache.enable: false
DEBUG POP3: mail.pop3.keepmessagecontent: false
DEBUG POP3: mail.pop3.starttls.enable: false
DEBUG POP3: mail.pop3.starttls.required: false
DEBUG POP3: mail.pop3.apop.enable: false
DEBUG POP3: mail.pop3.disablecapa: false
DEBUG POP3: connecting to host "pop.mail.yahoo.com", port 110, isSSL false
S: +OK hello from popgate-0.8.0.357900 pop001.mail.ir2.yahoo.com
C: CAPA
S: +OK CAPA list follows
IMPLEMENTATION popgate-0.8.0.357900
XOIP
EXPIRE-NEVER
PIPELINING
RESP-CODES
TOP
UIDL
USER
SASL LOGIN PLAIN
STLS
.
DEBUG POP3: PIPELINING enabled
DEBUG POP3: authentication command trace suppressed
DEBUG POP3: authentication command failed
C: QUIT
S: +OK
javax.mail.AuthenticationFailedException: [AUTH] Access to this service is not permitted.
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:208)
at javax.mail.Service.connect(Service.java:295)
at javax.mail.Service.connect(Service.java:176)
at dong.pong.ping.Client.main(Client.java:42)

代码:

String smtpHost = "smtp.mail.yahoo.com";
String popHost = "pop.mail.yahoo.com";
String from = "classified@yahoo.com";
String to = "classified@yahoo.com";
String username = "classified";
String password = "secret";

// Get system properties
Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port", 587);

// Get session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);

Store store = session.getStore("pop3");
store.connect(popHost, username, password);

// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to Yahoo's JavaMail");

// Send message
Transport.send(message);

如果你们有有效的代码,可以发布吗?谢谢

最佳答案

您有高级帐户吗?

Or is it a Yahoo problem?

Moved to the appropriate forum, but some versions of yahoo (specifically yahoo.com) do not support POP3 access to mail unless you have signed up for a premium account or have a partner service (like AT&T/Yahoo). When it says "Access is not permitted", that's probably what it means - you don't have a premium account.

[AUTH] Access to this service is not permitted

编辑:另见 Java Mail: Unable to send email via Yahoo工作示例。

关于java - 如何通过 JavaMail 从 Yahoo 服务器发送电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12990183/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com