Open API랑 Gmail 서버를 활용한 메일 전송기능을 하는 java Application 운영중에 전송되어야 할 것들이 누락되어 확인해보니...
java.net.unknownhostexception 에러가 발생했었다.
원인은 도메인이 잘못되었을 경우라고 하는데, 잘 작동되다가 간헐적으로 안된 것을 보면 통신 할 곳 IP찾으러 DNS로 접근하면서 뭔가 잘못된것이 아닐까..?(내 생각)
어쨋든, 문제를 해결하려면 hosts 파일을 수정해주어야 한다고 한다.
hosts파일에 통신 할 IP와 도메인 주소를 작성해놓으면 DNS로 접근하지 않고 바로 IP주소에 접근할 수 있다고 한다.
나는 Windows 2012 서버 운영중이니..
C:\Windows\System32\drivers\etc\hosts 파일에 사용하는 IP와 도메인을 입력해주었다.
ex) 108.177.125.108 smtp.gmail.com
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# Gmail
108.177.125.108 smtp.gmail.com
아직 문제가 해결되었는지 확인은 안된다... 기다려봐야겠다.