0

In the broadleaf demo site, after ordering I have seen..

A confirmation email has been sent to xyz@abc.com

But the email doesn't seem to go because it wasn't configured. I tried making these changes to my applicationContext-email.xml file.

<?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>

I have also seen a class called SendOrderConfirmationEmailActivity class. This class seems to send the email. This is listed in the activities in applicationContext-workflow.xml but I am getting the following exception.

[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)

Could you tell me the way of how to send order confirmation email?

I am using Broadleaf commerce demo 3.1.0-GA version.

JavaTechnical
  • 8,846
  • 8
  • 61
  • 97

1 Answers1

1

You seem to have two blMessageCreator beans defined, the second a NullMessageCreator. I would remove the latter from your configuration and try again.

My configuration is more or less the same as your's except with just the ThymeleafMessageCreator defined. I reproduced your issue by adding the second blMessageCreator definition.

Also you mention seeing the SendOrderConfirmationEmailActivity class. Just be sure to check that you have an implementation of SendOrderConfirmationEmailActivity (if you didn't fork from a recent DemoSite version). You will need to provide this to link it up in the blCheckoutWorkflow which you override in applicationContext-workflow.xml. I believe you can find a demo implementation in the DemoSite app here.

Hope this gets you going.

waltron
  • 131
  • 9