javamail - Java Mail authentication and connection -
while trying connect through java mail server responding unexpected
the problem same program connects , mails times throws
javax.mail.authenticationfailedexception: eof on socket @ com.sun.mail.pop3.pop3store.protocolconnect(pop3store.java:208) @ javax.mail.service.connect(service.java:295) @ javax.mail.service.connect(service.java:176) @ newpackage.pmspop3client.main(pmspop3client.java:44)
error
when server says
s: +ok hello there. c: capa s: +ok here's can do:
i can connect , fetch mails
s: eof
i cant connect server
my code
import java.util.; import javax.mail.; import javax.mail.event.connectionevent; import javax.mail.event.connectionlistener; import javax.mail.internet.*;
public class pmspop3client {
public static void main(string[] args) throws exception { try { string host = "host"; string user = "user"; string password = "pass"; properties props = system.getproperties(); session session = session.getdefaultinstance(props); session.setdebug(true); store store = session.getstore("pop3"); system.out.println("store.geturlname() = " + store.geturlname()); store.connect(host, user, password); folder folder = store.getfolder("inbox"); folder.open(folder.read_only); message[] messages = folder.getmessages(); (int = 0; < messages.length; i++) { system.out.println("------------ message " + (i + 1) + " ------------"); string = internetaddress.tostring(messages[i].getfrom()); if (from != null) { system.out.println("from: " + from); } string replyto = internetaddress.tostring( messages[i].getreplyto()); if (replyto != null) { system.out.println("reply-to: " + replyto); } string = internetaddress.tostring( messages[i].getrecipients(message.recipienttype.to)); if (to != null) { system.out.println("to: " + to); } string cc = internetaddress.tostring( messages[i].getrecipients(message.recipienttype.cc)); if (cc != null) { system.out.println("cc: " + cc); } string bcc = internetaddress.tostring( messages[i].getrecipients(message.recipienttype.bcc)); if (bcc != null) { system.out.println("bcc: " + to); } string subject = messages[i].getsubject(); if (subject != null) { system.out.println("subject: " + subject); } date sent = messages[i].getsentdate(); if (sent != null) { system.out.println("sent: " + sent); } date received = messages[i].getreceiveddate(); if (received != null) { system.out.println("received: " + received); } system.out.println(); } folder.close(true); store.close(); } catch (exception e) { e.printstacktrace(); } } }
you should try using pop3s protocal instead of pop3 following
store store = session.getstore("pop3s");
Comments
Post a Comment