发送电子邮件:连接失败

发布于 2024-08-25 19:10:06 字数 871 浏览 1 评论 0原文

我正在使用java发送邮件。 我想将发件人邮件 ID 设置为 [电子邮件受保护]。 当我使用它发送邮件时,会生成以下异常。

    Exception in thread "main" javax.mail.AuthenticationFailedException: failed to connect
    at javax.mail.Service.connect(Service.java:322)
    at javax.mail.Service.connect(Service.java:172)
    at javax.mail.Service.connect(Service.java:121)
    at javax.mail.Transport.send0(Transport.java:190)
    at javax.mail.Transport.send(Transport.java:120)
    at sendmailtoclient.SendSMTP.sendMail(SendSMTP.java:125)
    at sendmailtoclient.SendSMTP.main(SendSMTP.java:153)

我为邮件帐户使用了正确的密码。 尽管我已成功使用[电子邮件受保护]。 如果您有代码请发布给我。

请帮我。

提前致谢。

I am using java to send mail.
I want to set the from mail id to [email protected].
When i am using that for sending mail the following exception is generated..

    Exception in thread "main" javax.mail.AuthenticationFailedException: failed to connect
    at javax.mail.Service.connect(Service.java:322)
    at javax.mail.Service.connect(Service.java:172)
    at javax.mail.Service.connect(Service.java:121)
    at javax.mail.Transport.send0(Transport.java:190)
    at javax.mail.Transport.send(Transport.java:120)
    at sendmailtoclient.SendSMTP.sendMail(SendSMTP.java:125)
    at sendmailtoclient.SendSMTP.main(SendSMTP.java:153)

I have used the correct password for the mail account.
although it I have used the [email protected] successfully.
If you have code please post to me.

Please help me.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不知在何时 2024-09-01 19:10:06

您的凭据似乎有误或未被 Gmail 接受。
您需要 SMTP 服务器来发送邮件。您可以使用安装在自己机器上的一个

此处有一个免费的。

另外检查一下是否添加了activation.jar

It looks like your credentials are wrong or not accepted by gmail.
You need SMTP server for sending mail. You can use one installed on your own machine

One free one is here.

Also check if you have added activation.jar

安静被遗忘 2024-09-01 19:10:06

大多数情况下,此错误是由于您的类路径上没有activation.jar 和mail.jar 造成的。将它们添加为 Maven 依赖项或添加到 WEB-INF/lib 中,应该没问题。

Mostly this error occurs from not having activation.jar and mail.jar on your classpath. Add them as a maven dependency or add in WEB-INF/lib and it should be fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文