2

Hi I upgrade my magento 2.2.3 to 2.2.8 where I have some custom functionality for emails.

After upgrading am getting

Fatal error: Uncaught Error: Call to undefined method Magento\Framework\Mail\Message\Interceptor::clearFrom() 

Fatal error: Uncaught Error: Call to undefined method Magento\Framework\Mail\Message\Interceptor::getRawContent() 

I have made plugin for public function \Magento\Email\Model\Transport

 beforeSendMessage(\Magento\Email\Model\Transport $subject)
        { 
           $message = $subject->getMessage()
           $body = $message->getBody()->getRawContent();
           $message->clearFrom();
           $message->setBody($bodyNew);
        }

its \Magento\Framework\Mail\Message

1

buddy I just check that class I'm also gonna share as well that class
Magento\Framework\Mail\Message;

<?php
/**
 * Mail Message
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Framework\Mail;

class Message extends \Zend_Mail implements MessageInterface
{
    /**
     * @param string $charset
     */
    public function __construct($charset = 'utf-8')
    {
        parent::__construct($charset);
        $this->setHeaderEncoding(\Zend_Mime::ENCODING_BASE64);
    }

    /**
     * Message type
     *
     * @var string
     */
    protected $messageType = self::TYPE_TEXT;

    /**
     * Set message body
     *
     * @param string $body
     * @return $this
     */
    public function setBody($body)
    {
        return $this->messageType == self::TYPE_TEXT ? $this->setBodyText($body) : $this->setBodyHtml($body);
    }

    /**
     * Set message body
     *
     * @return string
     */
    public function getBody()
    {
        return $this->messageType == self::TYPE_TEXT ? $this->getBodyText() : $this->getBodyHtml();
    }

    /**
     * Set message type
     *
     * @param string $type
     * @return $this
     */
    public function setMessageType($type)
    {
        $this->messageType = $type;
        return $this;
    }
}

so as you can see that there is no any function getRawContent() or clearFrom() so they may updated that as well in the updated version thats why its not working

  • this is really bad :( – Daniel_12 Apr 12 '19 at 20:44
  • you fixed?this isssue – imtiazau Nov 21 '19 at 8:12

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.