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' => 'someemail@email.com', 'name' => 'SenderName'));`


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

  • can you send mails with plain PHP? you should verify this first – Philipp Sander Feb 21 '19 at 14:19
  • can you provide a little context to the method beforeSendMessage? that snippet can't work because $message is not defined – HelgeB Feb 21 '19 at 14:22
  • updated question – Daniel_12 Feb 21 '19 at 14:23
  • am getting problem with just setFrom method, everything else is working – Daniel_12 Feb 21 '19 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 Feb 21 '19 at 14:33

Instead of array passing string will solve the probelm

 public function beforeSendMessage(\Magento\Email\Model\Transport $subject)    {
        $message = $subject->getMessage();

| improve this answer | |

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.