1

I have setup email address in sales representative but getting sales email from

apache@domainname

So where I need to fix this issue? Can anyone let me know?

Other emails except sales are working fine.

  • 1
    Please check my ans, as I had same issue before and I have solved it. – Aasim Goriya Sep 8 '18 at 6:10
  • Okay, I am trying. – Vinod Kumar Sep 8 '18 at 6:13
  • ok please let me know if anything – Aasim Goriya Sep 8 '18 at 6:40
5

Source: https://github.com/sashas777/bug-from-email

Issue on Magento's GitHub Repo: https://github.com/magento/magento2/issues/14952

Please check following steps to resolve this issue.

Create your custom module to rewrite core files

In your /Vendor/Module/etc/di.xml add following code

<?xml version="1.0" ?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Sales\Model\Order\Email\SenderBuilder" type="Vendor\Module\Rewrite\Sales\Model\Order\Email\SenderBuilder" />
    <preference for="Magento\Framework\Mail\Template\TransportBuilder" type="Vendor\Module\Rewrite\Framework\Mail\Template\TransportBuilder" />
</config>

In your /Vendor/Module/etc/module.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
        <module name="Vendor_Module" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Sales"/>
        </sequence>
    </module>
</config>

In your Vendor/Module/Rewrite/Framework/Mail/Template/TransportBuilder.php

<?php

namespace Vendor\Module\Rewrite\Framework\Mail\Template;
class TransportBuilder extends \Magento\Framework\Mail\Template\TransportBuilder
{
    /**
     * @param $from
     * @param $store
     * @return $this
     * @throws \Magento\Framework\Exception\MailException
     */
    public function setFromByStore($from, $store)
    {
        $result = $this->_senderResolver->resolve($from, $store);
        $this->message->setFrom($result['email'], $result['name']);
        return $this;
    }
}

In your Vendor/Module/Rewrite/Sales/Model/Order/Email/SenderBuilder.php

<?php

namespace Vendor\Module\Rewrite\Sales\Model\Order\Email;
class SenderBuilder extends \Magento\Sales\Model\Order\Email\SenderBuilder
{
    /**
     * Configure email template
     *
     * @return void
     */
    protected function configureEmailTemplate()
    {
        $this->transportBuilder->setTemplateIdentifier($this->templateContainer->getTemplateId());
        $this->transportBuilder->setTemplateOptions($this->templateContainer->getTemplateOptions());
        $this->transportBuilder->setTemplateVars($this->templateContainer->getTemplateVars());
        /*Send From Email Issue #Dev110*/
        $this->transportBuilder->setFromByStore(
            $this->identityContainer->getEmailIdentity(),
            $this->identityContainer->getStore()->getId()
        );
        /*Send From Email Issue #Dev110*/
//        $this->transportBuilderByStore->setFromByStore(
//            $this->identityContainer->getEmailIdentity(),
//            $this->identityContainer->getStore()->getId()
//        );
    }
}
  • 1
    Perfect...this is working fine for me. thank you – Vinod Kumar Sep 8 '18 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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