0

很抱歉重复的问题。

但我不明白这个错误是如何发生的......当我发送邮件时(使用 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
4

3 回答 3

3

这有点奇怪。例外情况是 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 主机。

于 2013-02-13T08:33:12.417 回答
1

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

于 2013-02-13T08:30:11.550 回答
0

smtp.live.com 应该可以工作。您很可能位于阻止直接 Internet 访问的公司防火墙后面,因此您无法查找名称。JavaMail FAQ提供了调试连接问题的技巧

于 2013-02-13T20:09:19.830 回答