Brook Preloader



Most of the times we send email to the customers or user on registration.

Emails sending is the one of the major topic in hybris. One of the longest process in Hybris .

Let us consider a new customer is registered in your store and you wanted to send him a custom welcome email. In this example we are concentrating only on email sending.

Step 1:   Creating a new customer at the same triggering the email service

In step one we have just created a customer and calling our email service method.

Step 2: Now Inside the Service implementation publish the event.

So that your event is get a call. In this example we are using CustomEmailEvent.

Step 3:Create a bean in respected spring.xml file

In this Example We are using core-spring.xml which is standard for services

Step 4: CustomEmailEvent is must extend with event listener class

Ex: CustomEmailEventListener extends AbstractAccelaratorSiteEventListener< CustomEmailEvent >

After extending the AbstractAccelaratorSiteEventListener class we have to implement the couple of method as shown in above image.onSiteEvent will create the process for email.Here we are using customEmailSendingProcess.

Step 5: Create an EventListener in respected spring.xml file

Step 6: Create a XMl file by Using same naming convention which as given in event listener.

Inside the xml the above content should be there and highlighted content is the bean to assign this process to one email template.

Step 7: Creating beans for customEmailSendingProcess in spring.xml

Note: While creating beans we must add DefinationResource for id it is mandatory.

In above image we can see CustomEmailTemplate is the template for this email process. We can use any naming convention but Starting letters must be capital

Step :8 Create the Email Context

In this example we CustomerEmailContent with is from out of the box.

If want we create our own Email Context We can create simple class and extends with AbstractEmailContext<>.

Step : 9 Preparing vm templates


Step :10 Preparing the Impex


$contentCatalog=<catalog name>


# Import modulegen config properties into impex macros

UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]



# Email velocity templates

INSERT_UPDATE RendererTemplate;code[unique=true];contextClass;rendererType(code)[default=’velocity’]



# Email page Template

INSERT_UPDATE EmailPageTemplate;$contentCV[unique=true];uid[unique=true];name;active;frontendTemplateName;subject(code);htmlTemplate(code);restrictedPageTypes(code)

;;CustomEmailTemplate;Custom Email Template;true;CustomEmail;Custom_Email_Subject;Custom_Email_Body;EmailPage

# Email Pages

INSERT_UPDATE EmailPage;$contentCV[unique=true];uid[unique=true];name;masterTemplate(uid,$contentCV);defaultPage;approvalStatus(code)[default=’approved’]

;;CustomEmail;Custom Email;CustomEmailTemplate;true


$contentCatalog=<catalog name>


# Import config properties into impex macros for modulegen

UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]


# Language


# CMS components and Email velocity templates

INSERT_UPDATE RendererTemplate;code[unique=true];description[lang=$lang];templateScript[lang=$lang,translator=de.hybris.platform.commerceservices.impex.impl.FileLoaderValueTranslator]

;Custom_Email_Subject;Owners PreLogin Subject;$emailResource/email-customEmailSubject.vm

;Custom_Email_Body;Owners PreLogin Body;$emailResource/email-customEmailBody.vm

# Email Pages

INSERT_UPDATE EmailPage;$contentCV[unique=true];uid[unique=true];fromEmail[lang=$lang];fromName[lang=$lang]

;;CustomEmail;””;”Customer Services Team”

Step 11: Import the above impex by using hac

After getting the import was successful .hit your api from post or browser

You will get following information in your cmd

If you can see the above message was successfully the email will be generated.

Step 12: If you have smtp you can use it or we can use fake smtp

In this example we are using fake smtp.

0 0 vote
Inline Feedbacks
View all comments