Reading email from gmail is not working

白昼怎懂夜的黑 提交于 2019-12-05 13:14:29

Change Your emailSession variable with

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

As said by Gmail

Some apps and devices use less secure sign-in technology, which makes your account more vulnerable. You can turn off access for these apps, which we recommend, or turn on access if you want to use them despite the risks. Learn more

Just click below link and disable Gmail security settings.It will work.

Disable Security settings

Here is a nice article about Password Authentication in Java Mail Api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!