How to Send Magento 2 Generated Dynamic PDF in Email to Customers

img how attach custom pdf to custom email template

Nowadays, Email has become a necessary part of the business for various purposes like company communications, marketing and coordinating with business partners, suppliers and customers. By Default, Magento 2 comes with built-in functionality of sending custom Emails to notify the customers as well as store owners for each and every activity. While working on extension development, we came across the requirement of generating, attaching & sending Magento 2 generated Dynamic PDF to customer Email. Throughout developing that functionality, we have tried & tested various code and finally, came out with a small piece of code that today I would like to share with you.

Mainly you need to create two separate files. One is to generate dynamic PDF and another one is to attach that PDF within mail.
Firstly Create Sendmail.php file at App/Code/Vendor/Extension/Controller/Index and write the following code in it.


Comment down below and let the below stars shine if the code has enough helped you to nail the solution.
Happy Mailing!
Previous Article

How to Send Product Images in Order Transaction Mail to Customers in Magento 2

Next Article

How to Add Additional Options in Magento 2

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨