씩씩이
25
2018-10-11 19:54:30 작성 2018-10-11 20:19:54 수정됨
1
71

자바 구글 메일 전송시 에러가 납니다.



개발환경에서는 이메일이 잘 발송되는데 

운영서버에서만 발송이 안됩니다.. 


방화벽 포트설정 문제이지 않을까 하는데.....  

포트를 뚫어줘야할것 같은데 

구글링 하다보니 smtp.gmail.com이 호스트ip가 계속 바뀐다고 다들 써놔서,... 

어떻게해야할까요 ? 

방화벽이 아니면 다른 문제가 있는 걸까요?


-----------------소스------------------

JavaMailSenderImpl mailSender = new JavaMailSenderImpl();

MimeMessage message = mailSender.createMimeMessage();

  

// Properties 설정  

Properties props = new Properties();  

props.put("mail.smtp.starttls.enable","true"); // 설정하지 않으면 에러 발생 (아래 참조)

props.put("mail.smtp.auth","true");

props.put("mail.smtp.quitwait","false");

props.put("mail.smtp.ssl.enable","false");  

props.put("mail.debug","true"); // 디버그 모드 : 개발이 완료되면 false


mailSender.setJavaMailProperties(props);

mailSender.setProtocol("smtp");

mailSender.setHost("smtp.gmail.com");

mailSender.setPort(587);

mailSender.setUsername("");

mailSender.setPassword("");

mailSender.setDefaultEncoding("utf-8");


try {

MimeMessageHelper messageHelper = new MimeMessageHelper(message, true, "UTF-8");

 

messageHelper.setSubject("");

messageHelper.setTo(email); // 받는사람

messageHelper.setFrom(""); // 보내는사람

messageHelper.setText(textDiv, true);  // 메일 내용

     

mailSender.send(message);



------------------에러로그 ----------

DEBUG: JavaMail version 1.4.1

DEBUG: not loading file: /opt/java6/jre/lib/javamail.providers

DEBUG: java.io.FileNotFoundException: /opt/java6/jre/lib/javamail.providers (?대?????????? ??????由ш? ???듬???? (errno:2))

DEBUG: !anyLoaded

DEBUG: not loading resource: /META-INF/javamail.providers

DEBUG: successfully loaded resource: /META-INF/javamail.default.providers

DEBUG: Tables of loaded providers

DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}

DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}

DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map

DEBUG: !anyLoaded

DEBUG: not loading resource: /META-INF/javamail.address.map

DEBUG: not loading file: /opt/java6/jre/lib/javamail.address.map

DEBUG: java.io.FileNotFoundException: /opt/java6/jre/lib/javamail.address.map (?대?????????? ??????由ш? ???듬???? (errno:2))

DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]

DEBUG SMTP: useEhlo true, useAuth true

DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL false

org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com. Failed messages: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com; message exception details (1) are:

Failed message 1:

javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com

        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1389)

        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)

        at javax.mail.Service.connect(Service.java:288)

        at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:389)

        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)

        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:336)

        at kr.go.binet.auth.controller.MemController.logListMngr(MemController.java:294)

        at kr.go.binet.auth.controller.MemController$$FastClassByCGLIB$$1564be4e.invoke(<generated>)

        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)

        at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)

        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)

        at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)

        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)

        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

        at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)

        at kr.go.binet.auth.controller.MemController$$EnhancerByCGLIB$$7ed4635c.logListMngr(<generated>)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)

        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)

        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)

        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)

        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)

        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)

        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)

        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)

        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)

        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)

        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

        at com.ckfinder.connector.MenuFilter.doFilter(MenuFilter.java:64)

        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

        at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)

        at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)

        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

        at egovframework.rte.ptl.mvc.filter.HTMLTagFilter.doFilter(HTMLTagFilter.java:51)

        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)

        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)

        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)

        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)

        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)

        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)

        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

Caused by: java.net.UnknownHostException: smtp.gmail.com

        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:223)

        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:365)

        at java.net.Socket.connect(Socket.java:545)

        at java.net.Socket.connect(Socket.java:494)

        at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)

        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)

        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)

        ... 53 more

2018-10-11 19:23:57,276 DEBUG [org.springframework.web.servlet.handler.SimpleMappingExceptionResolver] Resolving exception from handler [kr.go.binet.auth.controller.MemController@56af5047]: org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com. Failed messages: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com; message exceptions (1) are:

Failed message 1: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com

2018-10-11 19:23:57,276 DEBUG [org.springframework.web.servlet.handler.SimpleMappingExceptionResolver] Resolving to default view 'cmmn/bizError' for exception of type [org.springframework.mail.MailSendException]

2018-10-11 19:23:57,276 DEBUG [org.springframework.web.servlet.handler.SimpleMappingExceptionResolver] Exposing Exception as model attribute 'exception'

2018-10-11 19:23:57,279 DEBUG [org.springframework.web.servlet.DispatcherServlet] Handler execution resulted in exception - forwarding to resolved error view: ModelAndView: reference to view with name 'cmmn/bizError'; model is {exception=org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com. Failed messages: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com; message exceptions (1) are:

Failed message 1: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com}

org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com. Failed messages: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com; message exception details (1) are:

Failed message 1:

javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com

        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1389)

        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)

        at javax.mail.Service.connect(Service.java:288)

        at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:389)

        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)

        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:336)

        at kr.go.binet.auth.controller.MemController.logListMngr(MemController.java:294)

        at kr.go.binet.auth.controller.MemController$$FastClassByCGLIB$$1564be4e.invoke(<generated>)

        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)

        at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)

        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)

        at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)

        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)

        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

        at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)

        at kr.go.binet.auth.controller.MemController$$EnhancerByCGLIB$$7ed4635c.logListMngr(<generated>)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)

        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)

        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)

        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)

        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)

        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)

        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)

        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)

        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)

        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)

        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

        at com.ckfinder.connector.MenuFilter.doFilter(MenuFilter.java:64)

        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

        at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)

        at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)

        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

        at egovframework.rte.ptl.mvc.filter.HTMLTagFilter.doFilter(HTMLTagFilter.java:51)

        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)

        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)

        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)

        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)

        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)

        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)

        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

Caused by: java.net.UnknownHostException: smtp.gmail.com

        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:223)

        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:365)

        at java.net.Socket.connect(Socket.java:545)

        at java.net.Socket.connect(Socket.java:494)

        at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)

        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)

        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)

        ... 53 more

2018-10-11 19:23:57,281 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Invoking afterPropertiesSet() on bean with name 'cmmn/bizError'

2018-10-11 19:23:57,281 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0'

2018-10-11 19:23:57,281 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'com.googlecode.ehcache.annotations.config.internalEhCacheCachingAdvisor'

2018-10-11 19:23:57,281 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0'

2018-10-11 19:23:57,281 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0'

2018-10-11 19:23:57,281 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'com.googlecode.ehcache.annotations.config.internalEhCacheCachingAdvisor'

2018-10-11 19:23:57,281 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0'

2018-10-11 19:23:57,285 DEBUG [org.springframework.web.servlet.view.UrlBasedViewResolver] Cached view [cmmn/bizError]

2018-10-11 19:23:57,285 DEBUG [org.springframework.web.servlet.DispatcherServlet] Rendering view [org.springframework.web.servlet.view.JstlView: name 'cmmn/bizError'; URL [/WEB-INF/jsp/cmmn/bizError.jsp]] in DispatcherServlet with name 'action'

2018-10-11 19:23:57,286 DEBUG [org.springframework.web.servlet.view.JstlView] Rendering view with name 'cmmn/bizError' with model {exception=org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com. Failed messages: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com; message exceptions (1) are:

Failed message 1: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

  nested exception is:

        java.net.UnknownHostException: smtp.gmail.com} and static attributes {}

0
0
  • 답변 1

  • 잡채밥냠냠
    127
    2018-10-12 00:01:02

    487말고 25번 포트로 바꿔도 그런가요?

    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.