14

春天的新人。我正在捕获以下异常:

2012-06-14 16:20:57,719 [http-8080-6] ERROR com.nimchip.lmu.data.service.impl.CoworkerServiceImpl - Error sending mail:
org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp. Failed messages: javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp
    at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:400) ~[spring-context-support-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:306) ~[spring-context-support-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:296) ~[spring-context-support-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at com.nimchip.lmu.data.service.impl.CoworkerServiceImpl.genUpdateNomination(CoworkerServiceImpl.java:224) ~[lmu-dataaccess-1.0.0.jar:na]
    at com.nimchip.lmu.controller.coworkerNom.CoworkerController.genUpdateNomination(CoworkerController.java:312)

我有一个在我的 web.xml 中注册的 mail-config.xml。这里是:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host" value="10.30.137.190"/>
        <property name="port" value="25"/>
    </bean>

</beans>

我应该能够匿名登录到指定的邮件服务器,因此不需要用户名或密码。

我错过了什么?

4

2 回答 2

30

你的类路径中有mail.jarandactivation.jar吗?

这些类应该提供 smtp-provider。

如果您使用的是 maven,只需将其添加到您的 pom 中:

    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4</version>
    </dependency>

    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.0.2</version>
    </dependency>
于 2012-06-14T20:33:56.587 回答
0

我有同样的问题。我使用 mailapi 作为工件 id,这导致了这个问题。我替换 <artifactId>mailapi</artifactId><artifactId>mail</artifactId>它工作正常

于 2015-05-26T16:33:50.793 回答