How Do You Send Mail in Magento2

In this generation, it is necessary to keep a well maintained and long lasting relationship between Online stores and customer. One of the best way to be connected with each other is email. In this blog, how do you send email in Magento2.

In this blog, below you can use the code to create a custom mail and send it to the customer.

$report= ['content'=>$html,];		
$objectManager 	= \Magento\Framework\App\ObjectManager::getInstance(); 
	     $this->_transportBuilder = $objectManager->create('\Magento\Framework\Mail\Template\TransportBuilder');
           $postObject = new \Magento\Framework\DataObject();
            $transport = $this->transportBuilder
                ->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])
                ->setTemplateVars(['data' => $postObject])
                ->setFrom(['name' => 'test','email' => ''])


You can apply the code in Magento development. Please share your reviews in the comment section.

We Serve clients globally in diverse industries

Stay Upto Date With Our Newsletter.