且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在netbeans swing应用程序中使用javamail api发送电子邮件?

更新时间:2022-11-16 23:04:18

需要注意的一点是,在大多数Google SMTP服务器的情况下,如果您的帐户不允许,它将不允许直接使用SMTP。在这种情况下,我看到许多开发人员编写了协议API的正确实现,但他们仍然无法发送电子邮件。在这种情况下,请确保您的帐户允许通过身份验证进行SMTP通信。它在您的设置中,检查它。



后来,问题仍然是authenti阳离子到您的帐户。例如,请参阅错误消息:



One thing to note is that, in most of the cases of Google SMTP server, is that it won't allow SMTP consumption directly, if your account doesn't allow. In many cases, I have seen that many developers have written a correct implementation of the protocol API, but still they cannot send the email. In that case, make sure that your account allows SMTP communication through your authentication. It is in your settings, check it.

Later, the problem is still the authentication to your account. For example, see the error message:

Quote:

javax.mail。 AuthenticationFailedException ...请通过Web浏览器登录,然后重试。

javax.mail.AuthenticationFailedException...Please log in via your web browser and then try again.

这表示您需要对系统进行身份验证才能使用该帐户。 Google不允许您的应用使用此功能。



以下其中一项原因可能是:



1.您的帐户是新帐户。谷歌打击垃圾邮件;或者这就是他们告诉我们的。 :笑:

2.确保您可以从网络浏览器登录帐户,试试运气: mail.google。 com

3.确保按照安全标准支持应用程序; SSL,端口和身份验证等。

4.更多。



这些是您需要保留的一些主要内容心神。您的代码是正确的,问题在于身份验证。用户名/密码不正确,否则Google会阻止您的应用进行通信。



此外,帮助网址为:可以登录我的电子邮件应用 - Gmail帮助 [ ^ ],你使用的是错误的。 :-)



如需更多信息,请阅读以下内容:



JavaMail API–通过Gmail SMTP示例发送电子邮件 [ ^ ]

java - 解决错误javax.mail.AuthenticationFailedException - 堆栈溢出 [ ^ ]

This tells that you need to authenticate the system to use that account. Google does not allow your application to use this.

One of the following may be the reason:

1. Your account is a new one. Google fights against spam; or that is what they tell us. :laugh:
2. Make sure you can sign in to account from web browser, try your luck at: mail.google.com.
3. Make sure application is supported as per security standards; SSL, port and authentication etc.
4. Much more.

These are a few of the major things that you need to keep in mind. Your code is correct, the problem is with authentication. Either the username/password is incorrect, otherwise Google is preventing your app to communicate.

Also, the help URL is: Can’t sign in to my email app - Gmail Help[^], you are using the wrong one. :-)

For more, please read these:

JavaMail API – Sending email via Gmail SMTP example[^]
java - Solve error javax.mail.AuthenticationFailedException - Stack Overflow[^]