Zain Sheikh
Zain Sheikh

Reputation: 21

Download Email using Gmail Server , 'Authentication Failed'

I want to download Email using Gmail Server , for that firstly i need to connect with it , Am using Pop3 Gmail Server for this , but 'Authentication Failed' error occur. code for connection is :

        Properties properties = new Properties();
    // server setting
    properties.put("mail.pop3.host",host);
    properties.put("mail.pop3.port",port);
    // SSL setting
    properties.setProperty("mail.pop3.socketFactory.class",
            "javax.net.ssl.SSLSocketFactory");
    properties.setProperty("mail.pop3.socketFactory.fallback", "false");
    properties.setProperty("mail.pop3.socketFactory.port",
            String.valueOf(port));
    Session session = Session.getDefaultInstance(properties);
    try {
        // connects to the message store
        Store store = session.getStore("pop3s");
        store.connect(userName, password);    //error at this line

Upvotes: 1

Views: 345

Answers (2)

Zain Sheikh
Zain Sheikh

Reputation: 21

Thankyou , bt it doesnot works , Issue was of Avast Antivirus , it was blocking to connect with mail server .

Upvotes: 0

Kennet
Kennet

Reputation: 5796

The problem is due to security settings in Gmail, if you add

emailSession.setDebug(true);

you will actually get a link to the error message, https://support.google.com/mail/answer/78754

Also found this

Upvotes: 2

Related Questions