gpt4 book ai didi

Java 邮件 API 和 Gmail

转载 作者:行者123 更新时间:2023-12-01 09:51:23 25 4
gpt4 key购买 nike

我知道以前这是可能的,但现在,当尝试以各种方式使用 Java 邮件 API 通过 gmail 帐户发送电子邮件时,gmail 会导致异常。 Gmail有自己的邮件API,需要oauth2.0身份验证。有没有办法使用Java自动使用gmail帐户发送电子邮件?

这是我得到的异常:

Exception in thread "main" java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuG
534-5.7.14 pnCDx7bYqYiAp9mjb1DPP3FApa-8RaN63YhQPOnG79CDnHBYQSBXvL6SGxPytaFyxSH4Qc
534-5.7.14 q0QS2LfefCQCG-PQs_bLaR6eCmAzFz1FqjKRS8JWyL9Hsa-8d1Hh1x_1cpRuqhVAC5Smg7
534-5.7.14 IOpErfFwkYr76t7GkEGbXgpxs2ZZyYP83Xi2ZWC06x2fWw8SOZPL9p5fO30TZw8lnTSpew
534-5.7.14 Kb8J0ODoPvSSoMtlQJp1NO65GsgxE> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 r76sm5990846wme.14 - gsmtp

at TestGmail.main(TestGmail.java:75)
Caused by: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuG
534-5.7.14 pnCDx7bYqYiAp9mjb1DPP3FApa- 8RaN63YhQPOnG79CDnHBYQSBXvL6SGxPytaFyxSH4Qc
534-5.7.14 q0QS2LfefCQCG-PQs_bLaR6eCmAzFz1FqjKRS8JWyL9Hsa- 8d1Hh1x_1cpRuqhVAC5Smg7
534-5.7.14 IOpErfFwkYr76t7GkEGbXgpxs2ZZyYP83Xi2ZWC06x2fWw8SOZPL9p5fO30TZw8lnTSpew
534-5.7.14 Kb8J0ODoPvSSoMtlQJp1NO65GsgxE> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 r76sm5990846wme.14 - gsmtp

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport. java:914)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:825)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:730)
at javax.mail.Service.connect(Service.java:388)
at javax.mail.Service.connect(Service.java:246)
at javax.mail.Service.connect(Service.java:195)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at TestGmail.main(TestGmail.java:70)

最佳答案

这是解决方案:

https://www.google.com/settings/security/lesssecureapps

安全性较低的应用程序访问显然是唯一的方法。

关于Java 邮件 API 和 Gmail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37576670/

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