send mail via SMTP Gmail Oauth2 issue

后端 未结 6 584
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 12:06

I can authenticated to SMTP by following the google example.

But the problem now is I can\'t send out the mail. I am getting the following error whenever I try to se

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 12:28

    I think so it is asking for authentication of your username.

    session=Session.getInstance(props,
             new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(fromUsername, password);
                }
              });
    

    And then use above session in your code.

    I haven't use the code specified in the google link u mentioned but i use java mail api to send email from my gmail account.Use above code for authentication

提交回复
热议问题