Magento – Fatal error: Class ‘Magento\Framework\Mail\Template\Zend_Mime’ not found in

magento-2.1

I put that function on the transpotbuilder file in core file , but it has still error:

Fatal error: Class 'Magento\Framework\Mail\Template\Zend_Mime' not
found in /var/www/html/vendor/magento/framework/Mail/Template

 public function addAttachment(
    $body,
    $mimeType    = Zend_Mime::TYPE_OCTETSTREAM,
    $disposition = Zend_Mime::DISPOSITION_ATTACHMENT,
    $encoding    = Zend_Mime::ENCODING_BASE64,
    $filename    = null
) {
    $this->message->createAttachment($body, $mimeType, $disposition, $encoding, $filename);
    return $this;
}

I added this function in core file and try to send attachment email and I got the Above error.

Best Answer

You need to add prefix slash() before zend_mime.

Clear var/generation folder and check,

 public function addAttachment(
    $body,
    $mimeType    = \Zend_Mime::TYPE_OCTETSTREAM,
    $disposition = \Zend_Mime::DISPOSITION_ATTACHMENT,
    $encoding    = \Zend_Mime::ENCODING_BASE64,
    $filename    = null
) {
    $this->message->createAttachment($body, $mimeType, $disposition, $encoding, $filename);
    return $this;
}

There are not any class related to

'Magento\Framework\Mail\Template\Zend_Mime.php

When you use prefix \ before the class they will route to Mime.php file from path vendor/magento/zendframework1/library/Zend/Mime.php

Related Topic