2013-02-13 106 views
0

對重複問題抱歉。未知的SMTP主機:smtp.live.com

,但我不理解這種錯誤怎麼來了...當我發送郵件(使用Hotmail)

聽到的是我的示例代碼..

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> 
    <property name="host" value="smtp.live.com" /> 
    <property name="port" value="587" /> 
    <property name="username" value="[email protected]" /> 
    <property name="password" value="**********" /> 

    <property name="javaMailProperties"> 
     <props> 
      <prop key="mail.smtp.auth">true</prop> 
      <prop key="mail.smtp.starttls.enable">true</prop> 
     </props> 
    </property> 
</bean> 

但我得到這個異常...

org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Unknown SMTP host: smtp.live.com; 
    nested exception is: 
    java.net.UnknownHostException: smtp.live.com. Failed messages: javax.mail.MessagingException: Unknown SMTP host: smtp.live.com; 
    nested exception is: 
    java.net.UnknownHostException: smtp.live.com; message exception details (1) are: 
Failed message 1: 
javax.mail.MessagingException: Unknown SMTP host: smtp.live.com; 
    nested exception is: 
    java.net.UnknownHostException: smtp.live.com 
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1280) 
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370) 
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) 
    at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) 
    at org.springframework.flex.core.MessageInterceptionAdvice.invoke(MessageInterceptionAdvice.java:66) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:124) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.aop.framework.Cglib2AopProxy$FixedChainStaticTargetInterceptor.intercept(Cglib2AopProxy.java:573) 
    at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$ace25600.serviceMessage(<generated>) 
    at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:103) 
    at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$ace25600.service(<generated>) 
    at org.springframework.flex.servlet.MessageBrokerHandlerAdapter.handle(MessageBrokerHandlerAdapter.java:109) 
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) 
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) 
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) 
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) 
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:662) 
Caused by: java.net.UnknownHostException: smtp.live.com 
+0

不是一個JavaMail問題,而只是懶惰的問題啓動器找出正確的SMTP域名。 – 2013-02-13 08:28:52

回答

1

smtp.live.com可能是過期的。 live.com的MX記錄通過mx4.hotmail.com指向mx1.hotmail.com;嘗試其中之一。

2

這有點奇怪。例外情況是說,smtp.live.com的DNS查找失敗。然而,當我做了查找的「smtp.live.com」我得到這個:

$ nslookup smtp.live.com 
Server:  10.0.0.138 
Address: 10.0.0.138#53 

Non-authoritative answer: 
smtp.live.com canonical name = smtp.hot.glbdns.microsoft.com. 
Name: smtp.hot.glbdns.microsoft.com 
Address: 65.55.162.200 

所以我懷疑,要麼你有一個臨時/本地DNS停運,或什麼是錯的與你的DNS CONFIGS。 DNS條目也有可能被撤銷......並且您的上游DNS緩存在我之前已過期。

嘗試自己做一個DNS查找並告訴我們它報告的內容。如果它失敗了,我建議你爲「live.com」/ hotmail /不管它自己調用它尋找一個更新的SMTP主機。

0

smtp.live.com應該工作。最有可能的是你在一個防止直接訪問互聯網的企業防火牆之後,所以你不能查找名字。 JavaMail FAQ有tips for debugging connection problems