Categories: How ToMagento 2

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

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!
Click to rate this post!
[Total: 3 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

22 hours ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

22 hours ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

2 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

3 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

5 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

5 days ago