Send mail from custom module Magento 2

To send custom email in Magento 2 using the module, We need to create a custom module to send email to a specific recipient.

Out of the box, Magento Provides multiple mail template, like Sales Order, Customer mails, Contacts and so on.

If you want to send your custom mail functionality using Magento 2, You need to create a simple module and create a custom template file using Module for mail body.

Continue reading “Send mail from custom module Magento 2”

How to get customer data by customer email in magento 2?

You can get customer information by just passing customer email using below code snippet, Create Block file,

Call getCustomerByEmail() function in template file,

Get all customer data by below way,
echo “<pre>”;print_r($customer->__toArray());

For, Get customer data by customer id using below link,

How to send image attachment with email template in magento 2

For Attach image in email template, you need to override TransportBuilder Class from Magento\Framework\Mail\Template\TransportBuilder

For Send Email Magento 2 without image attachment refer link,  Send Mail from Custom module Magento 2

For Override TransportBuilder.php file in Magento 2, you need to create di.xml file.
Using di.xml file you can override any PHP class in Magento 2.

Continue reading “How to send image attachment with email template in magento 2”