【问题标题】:Sending email: failed to connect发送电子邮件:连接失败
【发布时间】:2010-03-18 12:10:57
【问题描述】:

我正在使用 java 发送邮件。 我想将 from mail id 设置为 xyz@chatmeter.com。 当我使用它发送邮件时,会生成以下异常..

    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)

我使用了正确的邮件帐户密码。 虽然我已经成功使用了 xyz@gmail.com。 如果你有代码,请发给我。

请帮帮我。

提前致谢。

【问题讨论】:

标签: java email setting


【解决方案1】:

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

一个免费一个是here

还要检查你是否添加了activation.jar

【讨论】:

    【解决方案2】:

    这个错误主要是因为你的类路径中没有activation.jar 和mail.jar。将它们添加为 maven 依赖项或添加到 WEB-INF/lib 中应该没问题。

    【讨论】:

      猜你喜欢
      • 2017-12-08
      • 1970-01-01
      • 2017-02-09
      • 2016-07-26
      • 1970-01-01
      • 2017-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多