未知的SMTP主机:smtp.live.com

时间:2013-02-13 08:25:53

标签: java spring hibernate javamail

对于重复的问题感到抱歉。

但我不知道这个错误是怎么来的......当我发送邮件时(使用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="narasimham@sitsonline.com" />
    <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

3 个答案:

答案 0 :(得分: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配置有问题。 DNS条目也可能正在被撤销......并且您的上游DNS缓存在我之前就已过期。

尝试自己进行DNS查询并告诉我们报告的内容。如果它失败了,我建议你为“live.com”/ hotmail /它自己调用的东西寻找一个更新的SMTP主机。

答案 1 :(得分:1)

smtp.live.com可能已过时。 live.com的MX记录通过mx4.hotmail.com指向mx1.hotmail.com;试试其中之一。

答案 2 :(得分:0)

smtp.live.com应该可行。很可能你是企业防火墙的后面,阻止直接的互联网访问,所以你不能查找名称。 JavaMail FAQ有tips for debugging connection problems