enter image description here

In this screenshot you can see sales order mail sending to multiple acounts . and It work good mail sending to all accounts which mention in Send Order Email Copy To This is hard code to give account. I am developing multi-vendor site. i want to give just those vendor's accounts for email which has items in this order.

Can anyone tell me how can give programmatically emails account instead of giving hardcode in frontend as shown in screenshot.

1 Answer 1


You need to override getEmailCopyTo() function of vendor/magento/module-sales/Model/Order/Email/Container/OrderIdentity.php

And write your custom code and returns an array of emails.

 * Return email copy_to list
 * @return array|bool
public function getEmailCopyTo()
    //Write custom code and returns array of emails

    $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId());
    if (!empty($data)) {
        return explode(',', $data);

    return false;

For Invoice Emails: vendor/magento/module-sales/Model/Order/Email/Container/InvoiceIdentity.php

For Shipment Emails: vendor/magento/module-sales/Model/Order/Email/Container/ShipmentIdentity.php

For creditmemo emails: vendor/magento/module-sales/Model/Order/Email/Container/CreditmemoIdentity.php

  • Dear @Prince ! where i mention custom emails ? [email protected],[email protected] etc ? in $data variable ?
    – HaFiz Umer
    Apr 3, 2019 at 7:35
  • @HaFizUmer I just mentioned original function. As per your question you need to pass emails programmatically, You can write your custom code and returns the array of email here Apr 3, 2019 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.