Search code examples
emailsap-commerce-cloudreply

How to set TO ADDRESS while sending an email in Hybris?


When user replies on a mail that he has received that should go to particular email id. I tried to give in DefaultEmailGenerationService.java but it didn't reflect.

Could any one suggest how it can be achieved?


Solution

  • Scenario 1:

    How to change fromEmail Address of an email in Hybris?

    As I mentioned in the comment if you want to set from emailAddress you can do that using Impex. Just find out what is your emailPage and set fromEmail and fromName.


    Scenario 2:

    How to set fix toAdress in Hybris for all email?

    If you want to send all emails to some fix toAddress, in that case, you need to override email and displayName in respective *EmailContext of renderer template.

    Let's just assume you want to override toAddress in customer registration flow. So here you need to find context class name form impex. Below are the renderer template for customer registration subject & body and CustomerEmailContext is the class name which will feed all data to this renderer.Now you just need to populate those data in init method of CustomerEmailContext.java


    Scenario 3:

    How to support multiple toAddress and attachments in Hybris?

    To support multiple toAddress & fromAddress, ccAddresses, bccAddresses and attachments.

    • You need to create custom fields(toAddressList, ccAddresses etc) in your *EmailContext and populate the value.
    • Override generate method of DefaultEmailGenerationService class.
    • Fetch your value from emailContext like emailContext.get("yourcustomFiled")
    • Modify createEmailMessage method in such way so you can pass all your custom fields(toAddressList, ccAddresses etc) to final DefaultEmailService

    You can find detail post here