gpt4 book ai didi

java - 我想使用java程序发送电子邮件。我收到如下异常

转载 作者:行者123 更新时间:2023-12-02 07:31:34 26 4
gpt4 key购买 nike

我遇到了这个异常:

javax.mail.MessagingException: Unknown SMTP host: server.gmail.com;
nested exception is:
java.net.UnknownHostException: server.gmail.com
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1280)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at com.SimpleSendEmail.main(SimpleSendEmail.java:33)
Caused by: java.net.UnknownHostException: server.gmail.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
... 7 more

我还包含了所需的 jar 文件。请帮我解决这个异常。

最佳答案

尝试使用 smtp.gmail.com 作为您的主机。

关于java - 我想使用java程序发送电子邮件。我收到如下异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12853777/

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