1

I am using Magento version 2.2.6 and trying to send custom email with attachment, but I am getting 500 error. I tried transportbuilder addattachment which is working in Magento 2.3.x and onwards. But facing issue in this version.

I am trying this code:

  $this->message->createAttachment(
            $pdfString,
            'application/pdf',
            \Zend_Mime::DISPOSITION_ATTACHMENT,
            \Zend_Mime::ENCODING_BASE64,
            'attatched.pdf'
        );

And getting this error [1]: https://i.stack.imgur.com/civfS.png

Kindly let me know how I can send email with attachment in Magento version 2.2.6.

Any help will be apperciated.

3

1 Answer 1

0

This worked for me!

$this->message->createAttachment(
                $pdfString,
               \Zend_Mime::TYPE_OCTETSTREAM,
               \Zend_Mime::DISPOSITION_ATTACHMENT,
               \Zend_Mime::ENCODING_BASE64,
               'attatched.pdf'
             );

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.