19

M2 does not come with out of the box however it is a feature built into the zend framework. Here is a good reference how to add this functionality into magento: https://blog.bitexpert.de/blog/sending-mails-with-attachments-in-magento-2/ In case link goes dead, create the following <?php namespace Your\CustomModule\Magento\Mail\Template; class ...


12

I have made a simple module to allow additional file types in the WYSIWYG editor. This module is available on GitHub https://github.com/experius/Magento-2-Module-Experius-WysiwygDownloads


8

As of Magento 2.2.7 the solutions described above do not work anymore since \Magento\Framework\Mail\Message dropped extending \Zend_Mail. To circumvent the lack of an easy way to add attachments through the transport builder (which currently seems to be the correct place for such a function), one needs to create a replacement for the TransportBuilder and ...


4

1) in your custom transport builder add the below function for atatchment: <?php namespace Magebees\Demo\Model\Mail; class TransportBuilder extends \Magento\Framework\Mail\Template\TransportBuilder { /** * @param Api\AttachmentInterface $attachment */ public function addAttachment($pdfString,$filename) { $attachment = new \...


4

Magento2.3 using ZendFramework2, Magento2.3 start deprecated us of ZendFramework1. In ZF2 ,createAttachment() and addAttachment(), are not available anymore, so the correct way of dealing with multipart e-mails is using the Zend\Mime package. See detail at https://zf2.readthedocs.io/en/release-2.2.3/modules/zend.mail.attachments.html


4

i stumbled upon the same problem und came up with an out-of-the-box solution, that only requires ftp/sftp-access: upload an pdf-icon (something like ) into a folder (named "pdf" for example) upload all your pdf files via ftp/sftp into the same folder (under /[webroot]/pub/media/wysiwyg/pdf (if you named the folder "pdf") ) if you want to link to a pdf, ...


2

The sendTransactional() method just delegates to Mage_Core_Model_Email_Template::send(), so just call the send method directly instead. public function send($email, $name = null, array $variables = array()) EDIT: You can use the Zend_Mail class if you just want to send an email with an attachment. For example: $mail = new Zend_Mail(); $mail->setFrom("...


2

If you are already using our Email Attachments extension you can make use of the event it emits to add additional attachments (this is how the extension itself does it). For the order confirmation email you would listen for the event fooman_emailattachments_before_send_order and then in your event observer class you can use something like this: public ...


2

Magento 2.3.x Compatible: This was my answer for Magento 2.3 since this was a top question on google and there seems to be a lot of people in the comments looking. There seems to be a lot of desire in other posts about overwriting the default TransportBuilder class via etc/di.xml, however the module I'm working on is so small that I don't want it to be ...


2

I've got Magento 2.1.x and I had to use a custom module to overwrite the settings in the module cms and enable pdf upload. Here how you get it done.


2

You can do it by adding "pdf" in the allowed extension section under vendor/magento/module-cms/etc/di.xml like below: <item name="allowed" xsi:type="array"> <item name="jpg" xsi:type="number">1</item> <item name="jpeg" xsi:type="number">1</item> <item name="png" xsi:type="number">1</item> <item ...


2

Yes, now it's needed to use ZF2 only. I'm no sure that the methods above will work smoothly. I found a better way to set this process. I have managed to create a new class for Magento\Framework\Mail\Message default one by implementing of the Magento\Framework\Mail\MailMessageInterface interface. See the code that I've used https://github.com/extait-com/...


2

You can add attechement by preference also then add to etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="\Vendor\Module\Mail\Template\TransportBuilder" type="\Vendor\...


2

https://extait.com/blog/how-to-send-email-with-attachment-in-magento-2-3/ As from above link add encoding concept.. public function setBodyAttachment($content, $fileName, $fileType) { $attachmentPart = $this->partFactory->create(); $attachmentPart->setContent($content) ->setType($fileType) ->setFileName($fileName) ...


2

Try this way Some of the functionalities in Magento 2.3.x is different from previous version. The reason is that in most cases the 2.3.x framework uses Zend Framework 2 (ZF2) and almost totally refuses to applyZend Framework 1 (ZF1). Magento\Framework\Mail\MailMessageInterface::createAttachment() So, due to this, the previous method is deprecated and ...


2

Try this way Some of the functionalities in Magento 2.3.x is different from previous version. The reason is that in most cases the 2.3.x framework uses Zend Framework 2 (ZF2) and almost totally refuses to applyZend Framework 1 (ZF1). Magento\Framework\Mail\MailMessageInterface::createAttachment() So, due to this, the previous method is deprecated and ...


2

Your overwrite looks good. Problem is where you send email. You maybe missing following part: $transport->setTemplateVars([]) OR $template->setVars([]); [Update] Replace addAttachment method by following code: /** * @param $body * @param $mimeType * @param $disposition * @param $encoding * @param null $filename * @return $this */ public ...


2

Here is my working code as below: Controller: Here we've to pass parameter as below line: $filePath = uploaded attachment file path. ->addAttachment(file_get_contents($filePath), $fileName, $fileType) public function execute() { $yourFolderName = 'careers-resumes/'; // "my_custom_file" is the HTML input file name $...


2

Ensure that you are using the right area code email_templates.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd"> <template id="..." label="This is email template" file="general_template.html" type="html" module=...


2

You can use Sebwite's product downloads module, Which is doing exactly same what you're looking for. https://github.com/Sebwite/Magento2-Product-Downloads


1

This extension works fine on Magento ver. 2.3.1, https://github.com/extait-com/email-attachment Just add a function in Extait/Attachment/Mail/Message.php, public function setFromAddress($fromAddress, $fromName = null) { $this->zendMessage->setFrom($fromAddress, $fromName); return $this; } and test it via command php bin/magento extait:test:...


1

Magento's default email sending class TransportBuilder does not by default provides attachments in mail, but you can do it manually by overriding and using Zend framework integrated into Magento. Here is a blog explaining the same - https://webkul.com/blog/attach-pdf-file-magento-2-email/


1

First add order id in your form $this->getOrder()->getId() <form id="doc-form" name="doc-form" method="post" action="<?php echo Mage::helper('adminhtml')->getUrl('adminhtml/sfupload/upload',array('form_key' => Mage::getSingleton('core/session')->getFormKey(),'order_id'=>$this->getOrder()->getId())); ?>" enctype="multipart/...


1

Magento_OfflinePayments::info/pdf/checkmo.phtml file cannot be found. This is due to a Core bug in 2.1, 2.2, maybe 2.3. Create a plugin to fix it : In app\code\Namespace\Module\etc\di.xml <?xml version="1.0" ?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/...


1

di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Fooman\EmailAttachments\Observer\BeforeSendInvoiceObserver" type="Myvendorfolder\EmailAttachments\Observer\BeforeSendInvoiceObserver" /> ...


1

Please Try Following methods in di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Sales\Model\Order\Pdf\Invoice" type="ExtensionName\Modulename\Model\Order\Pdf\Invoice"/> <...


1

After research, I have found the way we can attach a dynamic image and PDF to order email. Kindly follow below steps to attach images to order email. Step 1: <preference for="Magento\Framework\Mail\Template\TransportBuilder" type="vendor\moduleName\Model\Mail\MailTransportBuilder"></preference> <preference for="Magento\Sales\Model\Order\...


1

You can use the event checkout_cart_product_add_after to modify the product image information. Firstly in your product detail page you need to add a hidden field in the add to cart form something like: <input type="hidden" name="[option][front_designurl]" id="front_designurl"/> And using javascript add the value to the field for the generated image ...


1

Here is perfect answer to send pdf in Email in magetno 2.3 $transport = $_transportBuilder->setTemplateIdentifier(20) ->setTemplateOptions($templateOptions) ->setTemplateVars($templateVars) ->setFrom($from) ->addTo($vendor_email) ->getTransport(); $html = $transport->...


1

Magento 2 Custom email from Module, Doesn't provide image attachment. If you want to use Image attachment with email templates in Magento 2 you need to override class, Magento\Framework\Mail\Template\TransportBuilder Magento Out-of-box doesn't provide attachment feature for email. You can refer blogs for send image attachment in details, You need to add ...


Only top voted, non community-wiki answers of a minimum length are eligible