JavaMail API : Username and Password not accepted (Gmail)

前端 未结 2 1157
不知归路
不知归路 2020-12-20 08:36

I want to send email from my java application to gmail account I used the following code and javaMail API ,But Gmail not accepted username and password and exception thrown

相关标签:
2条回答
  • 2020-12-20 08:56

    You can try to allow unsecure applications, it worked for me.

    Steps for Gmail account :

    1. Sign in to Gmail
    2. Click here to access Less Secure App Access in My Account.
    3. Next to “Allow less secure apps: OFF,” select the toggle switch to turn ON.

    See this link for Gmail and G-Suite.

    0 讨论(0)
  • 2020-12-20 09:18

    To be able send mail messages via your gmail account, you should allow unsecure applications (which your application is by gmail's point of view) in google account security settings.

    UPD: Also, if you want to see debug messages, use next java mail property:

    props.put("mail.debug", "true");
    

    It can help you to find out what happening behind the scenes.

    0 讨论(0)
提交回复
热议问题