2

I sending email from one custom module so everything is working fine but If I change from , I am not getting emails.

 public function beforeSendMessage(\Magento\Email\Model\Transport $subject)    {
    $message = $subject->getMessage();
    $message->setFrom(array('email' => '[email protected]', 'name' => 'SenderName'));`

}

I tried Sales Emails going via wrong email address magento 2.2.x but doesnt help

9
  • can you send mails with plain PHP? you should verify this first Commented Feb 21, 2019 at 14:19
  • can you provide a little context to the method beforeSendMessage? that snippet can't work because $message is not defined
    – HelgeB
    Commented Feb 21, 2019 at 14:22
  • updated question
    – Daniel_12
    Commented Feb 21, 2019 at 14:23
  • am getting problem with just setFrom method, everything else is working
    – Daniel_12
    Commented Feb 21, 2019 at 14:24
  • OK, I guess that's a plugin before the sendMesage method. You might get a problem if there is an attempt to set the from header twice - but that should throw an exception from Zend_Mail class. You can try $message->clearFrom() before
    – HelgeB
    Commented Feb 21, 2019 at 14:33

1 Answer 1

0

Instead of array passing string will solve the probelm

 public function beforeSendMessage(\Magento\Email\Model\Transport $subject)    {
        $message = $subject->getMessage();
        $message->clearFrom();
        $message->setFrom('[email protected]',);

    }

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.