sitelink1 https://sites.google.com/site/parn755/home/java 
sitelink2  
sitelink3  
sitelink4  
sitelink5  
sitelink6  

I tried to find out how to connect gmail server and retrieve mails but most information seem to be too old/ambigous or they do not show complete code. 

So I'm trying to make valid sources. Below code just makes connection to pop3 server.

 

 

 

referenced links:

https://javamail.java.net/nonav/docs/JavaMail-1.5.pdf : Javamail API document ver 1.5

http://www.oracle.com/technetwork/java/javamail/faq/index.html#commonmistakes : Javamail FAQ

 

 

 

 

 

Source: 

 

import java.util.Properties;

import javax.mail.Folder;

import javax.mail.MessagingException;

import javax.mail.Session;

import javax.mail.Store;

import javax.mail.URLName;

 

public class ReadTest {

 static String protocol = "pop3";

 static String host = "pop.gmail.com";

 static String user = "gmail ID";

 static String password = "password";

 static String port = "995";

 static String url = null;

 static String root = null;

 static String pattern = "%";

 static boolean recursive = false;

 static boolean verbose = false;

 static boolean debug = true;

 

 public static void main(String[] args) {

  // Get a Properties object

  Properties props = System.getProperties();

  

  // Let's check out what's in default Properties

  System.out.println(props.toString());

  

  //Before opening session, set port number and ssl authentication

  props.put("mail.pop3.port", "995");

  props.put("mail.pop3.ssl.enable", "true");

  

  //properties are added correctly?

  System.out.println(props.toString());

  

  // Get a Session object

  Session session = Session.getInstance(props, null);

  

  // let's see what's going on by setting debug as true

  session.setDebug(debug);

  // Get a Store object

  Store store = null;

  Folder rf = null;  

  

  

  try {

   if (url != null) {

    URLName urln = new URLName(url);

    store = session.getStore(urln);

    store.connect();

   } else {

    if (protocol != null) {

     store = session.getStore(protocol);

    }

    else {

     store = session.getStore();    

    }

    // Connect

    if (host != null || user != null || password != null) {   

     store.connect(host, user, password);

    }

    else {

     store.connect();

    }

   }

  } catch (MessagingException e) {

   // TODO Auto-generated catch block

   e.printStackTrace();

  }

 }

 

}

 

 

 

 

 

 

Result (omitted properties values)

 

DEBUG: setDebug: JavaMail version 1.5.0

DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]

DEBUG POP3: mail.pop3.rsetbeforequit: false

DEBUG POP3: mail.pop3.disabletop: false

DEBUG POP3: mail.pop3.forgettopheaders: false

DEBUG POP3: mail.pop3.cachewriteto: false

DEBUG POP3: mail.pop3.filecache.enable: false

DEBUG POP3: mail.pop3.keepmessagecontent: false

DEBUG POP3: mail.pop3.starttls.enable: false

DEBUG POP3: mail.pop3.starttls.required: false

DEBUG POP3: mail.pop3.apop.enable: false

DEBUG POP3: mail.pop3.disablecapa: false

DEBUG POP3: connecting to host "pop.gmail.com", port 995, isSSL true

+OK Gpop ready for requests from 61.75.27.199 yw8pf6744109pac.0

CAPA

+OK Capability list follows

USER

RESP-CODES

EXPIRE 0

LOGIN-DELAY 300

TOP

UIDL

X-GOOGLE-VERHOEVEN

X-GOOGLE-RICO

.

DEBUG POP3: authentication command trace suppressed

DEBUG POP3: authentication command succeeded

 

 

번호 제목 글쓴이 날짜 조회 수
283 수치 데이터 처리 유틸리티 file 황제낙엽 2019.05.12 1907
282 한글 초성 중성 종성 분리 유틸리티(자작) file 황제낙엽 2019.05.07 525
281 한글 초성 중성 종성 분리 (자모분리) 황제낙엽 2019.05.07 458
280 한글 인코딩의 이해 1편: 한글 인코딩의 역사와 유니코드 황제낙엽 2019.05.07 501
279 한글 인코딩의 이해 2편: 유니코드와 Java를 이용한 한글 처리 file 황제낙엽 2019.05.07 509
278 응답 헤더의 Content-disposition 속성 황제낙엽 2019.04.16 824
277 StringUtils - 문자열 처리 유틸리티 file 황제낙엽 2019.04.15 517
276 JSON과 GSON 황제낙엽 2019.03.24 594
275 File.length() 에 대하여 황제낙엽 2019.03.24 523
274 File.delete() 와 File.deleteOnExit() 황제낙엽 2019.03.24 2602
273 List to Array / Array to List 황제낙엽 2019.03.24 412
272 Oracle JAVA 유료화에 관련한 최신 기사 황제낙엽 2019.01.23 472
271 [HttpURLConnection, HttpsURLConnection] 코드참조용 샘플프로젝트 secret 황제낙엽 2019.01.18 0
270 Iterator.next() - NoSuchElementException 황제낙엽 2018.10.28 639
269 OracleJDK 유료화 FAQ (Oracle Java 의 유료화에 대한 어느분의 정리) 황제낙엽 2018.10.11 492
268 메일서버(daum.net)에 POP3를 이용하여 메일 가져오기 예제 file 황제낙엽 2018.10.09 1325
267 Sending mail through Java using SMTP of gmail file 황제낙엽 2018.09.13 830
266 Read or get mails using pop in java (using gmail) file 황제낙엽 2018.09.13 11657
265 Collections.sort() , Comparator 황제낙엽 2018.08.23 556
» JavaMail - Connecting Gmail pop3 server. 황제낙엽 2018.08.20 711