在阔叶演示网站上,订购后我见过..
确认电子邮件已发送至xyz@abc.com
但电子邮件似乎没有,因为它没有配置。我尝试对applicationContext-email.xml
文件进行这些更改。
<?xml version="1.0" encoding="UTF-8"?>
<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-3.2.xsd">
<!-- A dummy mail sender has been set to send emails for testing purposes only
To view the emails sent use "DevNull SMTP" (download separately) with the following setting:
Port: 30000 -->
<bean id="blMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host"><value>smtp.mandrillapp.com</value></property>
<property name="port"><value>900</value></property>
<property name="protocol"><value>smtp</value></property>
<property name="username"><value>xyz@abc.com</value></property>
<property name="password"><value>mypassword</value></property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.smtp.timeout">25000</prop>
<prop key="mail.smtp.auth">true</prop>
</props>
</property>
</bean>
<bean id="blEmailTemplateResolver" class="org.thymeleaf.templateresolver.ClassLoaderTemplateResolver">
<property name="prefix" value="emailTemplates/" />
<property name="suffix" value=".html" />
<property name="cacheable" value="${cache.page.templates}"/>
<property name="cacheTTLMs" value="${cache.page.templates.ttl}" />
</bean>
<bean id="blEmailTemplateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
<property name="templateResolvers">
<set>
<ref bean="blEmailTemplateResolver" />
</set>
</property>
<property name="dialects">
<set>
<bean class="org.thymeleaf.spring3.dialect.SpringStandardDialect" />
<ref bean="blDialect" />
</set>
</property>
</bean>
<bean id="blMessageCreator" class="org.broadleafcommerce.common.email.service.message.ThymeleafMessageCreator">
<constructor-arg ref="blEmailTemplateEngine"/>
<constructor-arg ref="blMailSender"/>
</bean>
<bean id="blMessageCreator" class="org.broadleafcommerce.common.email.service.message.NullMessageCreator">
<constructor-arg ref="blMailSender"/>
</bean>
<bean id="blEmailInfo" class="org.broadleafcommerce.common.email.service.info.EmailInfo">
<property name="fromAddress"><value>support@mycompany.com</value></property>
<property name="sendAsyncPriority"><value>2</value></property>
<property name="sendEmailReliableAsync"><value>false</value></property>
</bean>
<bean id="blRegistrationEmailInfo" parent="blEmailInfo">
<property name="subject" value="You have successfully registered!"/>
<property name="emailTemplate" value="register-email"/>
</bean>
<bean id="blForgotPasswordEmailInfo" parent="blEmailInfo">
<property name="subject" value="Reset password request"/>
<property name="emailTemplate" value="resetPassword-email"/>
</bean>
<bean id="blOrderConfirmationEmailInfo" parent="blEmailInfo">
<property name="subject" value="Your order with The Heat Clinic"/>
<property name="emailTemplate" value="orderConfirmation-email"/>
</bean>
</beans>
我还看过一个名为SendOrderConfirmationEmailActivity
类的类。这堂课好像发了电子邮件。这列在applicationContext-workflow.xml
中的活动中,但我收到以下异常。
[ERROR] 00:07:19 ContextLoader - Context initialization failed
[artifact:mvn] org.springframework.beans.FatalBeanException: Unable to merge source and patch locations; nested exception is org.broadleafcommerce.common.extensibility.context.merge.exceptions.MergeException: java.lang.NullPointerException
[artifact:mvn] at org.broadleafcommerce.common.extensibility.context.MergeApplicationContextXmlConfigResource.getConfigResources(MergeApplicationContextXmlConfigResource.java:86)
[artifact:mvn] at org.broadleafcommerce.common.web.extensibility.MergeXmlWebApplicationContext.loadBeanDefinitions(MergeXmlWebApplicationContext.java:130)
[artifact:mvn] at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
您能否告诉我如何发送订单确认电子邮件?
我正在使用 Broadleaf commerce demo 3.1.0-GA 版本。
答案 0 :(得分:1)
您似乎定义了两个blMessageCreator bean,第二个是NullMessageCreator。我会从你的配置中删除后者,然后再试一次。
我的配置或多或少与您的配置相同,只是定义了ThymeleafMessageCreator。我通过添加第二个blMessageCreator定义来重现您的问题。
另外,您提到了SendOrderConfirmationEmailActivity类。请务必检查您是否有SendOrderConfirmationEmailActivity的实现(如果您没有从最近的DemoSite版本派生)。您需要提供此链接以在applicationContext-workflow.xml中覆盖的blCheckoutWorkflow中将其链接起来。我相信您可以在DemoSite应用here中找到演示实现。
希望这能让你前进。